diff src/normal.c @ 3701:9f48a5432997 v7.3.610

updated for version 7.3.610 Problem: Cannot operate on the text that a search pattern matches. Solution: Add the "gn" and "gN" commands. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 25 Jul 2012 15:06:34 +0200
parents b9aa7fb4a928
children baba6286c91e
line wrap: on
line diff
--- a/src/normal.c
+++ b/src/normal.c
@@ -1780,10 +1780,18 @@ do_pending_operator(cap, old_col, gui_ya
 	    {
 		/* Prepare for redoing.  Only use the nchar field for "r",
 		 * otherwise it might be the second char of the operator. */
-		prep_redo(oap->regname, 0L, NUL, 'v',
-				get_op_char(oap->op_type),
-				get_extra_op_char(oap->op_type),
-				oap->op_type == OP_REPLACE ? cap->nchar : NUL);
+		if (cap->cmdchar == 'g' && (cap->nchar == 'n'
+							|| cap->nchar == 'N'))
+		    /* "gn" and "gN" are a bit different */
+		    prep_redo(oap->regname, 0L, NUL, cap->cmdchar, cap->nchar,
+					get_op_char(oap->op_type),
+					get_extra_op_char(oap->op_type));
+		else
+		    prep_redo(oap->regname, 0L, NUL, 'v',
+					get_op_char(oap->op_type),
+					get_extra_op_char(oap->op_type),
+					oap->op_type == OP_REPLACE
+							  ? cap->nchar : NUL);
 		if (!redo_VIsual_busy)
 		{
 		    redo_VIsual_mode = resel_VIsual_mode;
@@ -7987,6 +7995,17 @@ nv_g_cmd(cap)
 	cap->arg = TRUE;
 	nv_visual(cap);
 	break;
+
+    /* "gn", "gN" visually select next/previous search match
+     * "gn" selects next match
+     * "gN" selects previous match
+     */
+    case 'N':
+    case 'n':
+	if (!current_search(cap->count1, cap->nchar == 'n'))
+	    beep_flush();
+
+	break;
 #endif /* FEAT_VISUAL */
 
     /*