Attached is a patch (in both the unified and context formats) to make the
discussed "am/im" text-object.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
*** a/runtime/doc/motion.txt
--- b/runtime/doc/motion.txt
***************
*** 662,667 **** i` *v_i`* *i`*
--- 662,687 ----
Special case: With a count of 2 the quotes are
included, but no extra white space as with a"/a'/a`.
+ am{char} *v_am* *am*
+ "a matched {char}". Selects the text from the
+ previous {char} until the next {char}.
+ Only works within one line.
+ When the cursor starts on a {char}, Vim will figure
+ out which {char} pairs are desired by searching from
+ the start of the line.
+ Any trailing white space is included, unless there is
+ none, then leading white space is included.
+ When used in Visual mode it is made characterwise.
+ Repeating this object in Visual mode another
+ {char}..{char} range is included. A count is
+ currently not used.
+
+ im{char} *v_im* *im*
+ Like am{char} but exclude the {char} and
+ repeating won't extend the Visual selection.
+ Special case: With a count of 2 the quotes are
+ included, but no extra white space as with am{char}.
+
When used after an operator:
For non-block objects:
For the "a" commands: The operator applies to the object and the white
*** a/runtime/doc/tags
--- b/runtime/doc/tags
***************
*** 4751,4756 **** aleph options.txt /*aleph*
--- 4751,4757 ----
alt intro.txt /*alt*
alt-input debugger.txt /*alt-input*
alternate-file editing.txt /*alternate-file*
+ am motion.txt /*am*
amiga-window starting.txt /*amiga-window*
and() eval.txt /*and()*
anonymous-function eval.txt /*anonymous-function*
***************
*** 6520,6525 **** if_ruby.txt if_ruby.txt /*if_ruby.txt*
--- 6521,6527 ----
if_sniff.txt if_sniff.txt /*if_sniff.txt*
if_tcl.txt if_tcl.txt /*if_tcl.txt*
ignore-errors eval.txt /*ignore-errors*
+ im motion.txt /*im*
improved-autocmds-5.4 version5.txt /*improved-autocmds-5.4*
improved-quickfix version5.txt /*improved-quickfix*
improved-sessions version5.txt /*improved-sessions*
***************
*** 8441,8446 **** v_a[ motion.txt /*v_a[*
--- 8443,8449 ----
v_a] motion.txt /*v_a]*
v_a` motion.txt /*v_a`*
v_ab motion.txt /*v_ab*
+ v_am motion.txt /*v_am*
v_ap motion.txt /*v_ap*
v_aquote motion.txt /*v_aquote*
v_as motion.txt /*v_as*
***************
*** 8488,8493 **** v_i[ motion.txt /*v_i[*
--- 8491,8497 ----
v_i] motion.txt /*v_i]*
v_i` motion.txt /*v_i`*
v_ib motion.txt /*v_ib*
+ v_im motion.txt /*v_im*
v_ip motion.txt /*v_ip*
v_iquote motion.txt /*v_iquote*
v_is motion.txt /*v_is*
*** a/src/normal.c
--- b/src/normal.c
***************
*** 9309,9314 **** nv_object(cap)
--- 9309,9319 ----
flag = current_quote(cap->oap, cap->count1, include,
cap->nchar);
break;
+ case 'm': /* "am" = a matching pair of characters */
+ cap->extra_char = plain_vgetc();
+ flag = current_quote(cap->oap, cap->count1, include,
+ cap->extra_char);
+ break;
#if 0 /* TODO */
case 'S': /* "aS" = a section */
case 'f': /* "af" = a filename */
diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt
index d40d825..8af2b6e 100644
--- a/runtime/doc/motion.txt
+++ b/runtime/doc/motion.txt
@@ -662,6 +662,26 @@ i` *v_i`* *i`*
Special case: With a count of 2 the quotes are
included, but no extra white space as with a"/a'/a`.
+am{char} *v_am* *am*
+ "a matched {char}". Selects the text from the
+ previous {char} until the next {char}.
+ Only works within one line.
+ When the cursor starts on a {char}, Vim will figure
+ out which {char} pairs are desired by searching from
+ the start of the line.
+ Any trailing white space is included, unless there is
+ none, then leading white space is included.
+ When used in Visual mode it is made characterwise.
+ Repeating this object in Visual mode another
+ {char}..{char} range is included. A count is
+ currently not used.
+
+im{char} *v_im* *im*
+ Like am{char} but exclude the {char} and
+ repeating won't extend the Visual selection.
+ Special case: With a count of 2 the quotes are
+ included, but no extra white space as with am{char}.
+
When used after an operator:
For non-block objects:
For the "a" commands: The operator applies to the object and the white
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 73475a9..405996e 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -4751,6 +4751,7 @@ aleph options.txt /*aleph*
alt intro.txt /*alt*
alt-input debugger.txt /*alt-input*
alternate-file editing.txt /*alternate-file*
+am motion.txt /*am*
amiga-window starting.txt /*amiga-window*
and() eval.txt /*and()*
anonymous-function eval.txt /*anonymous-function*
@@ -6520,6 +6521,7 @@ if_ruby.txt if_ruby.txt /*if_ruby.txt*
if_sniff.txt if_sniff.txt /*if_sniff.txt*
if_tcl.txt if_tcl.txt /*if_tcl.txt*
ignore-errors eval.txt /*ignore-errors*
+im motion.txt /*im*
improved-autocmds-5.4 version5.txt /*improved-autocmds-5.4*
improved-quickfix version5.txt /*improved-quickfix*
improved-sessions version5.txt /*improved-sessions*
@@ -8441,6 +8443,7 @@ v_a[ motion.txt /*v_a[*
v_a] motion.txt /*v_a]*
v_a` motion.txt /*v_a`*
v_ab motion.txt /*v_ab*
+v_am motion.txt /*v_am*
v_ap motion.txt /*v_ap*
v_aquote motion.txt /*v_aquote*
v_as motion.txt /*v_as*
@@ -8488,6 +8491,7 @@ v_i[ motion.txt /*v_i[*
v_i] motion.txt /*v_i]*
v_i` motion.txt /*v_i`*
v_ib motion.txt /*v_ib*
+v_im motion.txt /*v_im*
v_ip motion.txt /*v_ip*
v_iquote motion.txt /*v_iquote*
v_is motion.txt /*v_is*
diff --git a/src/normal.c b/src/normal.c
index 9349be2..a96e0a6 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -9309,6 +9309,11 @@ nv_object(cap)
flag = current_quote(cap->oap, cap->count1, include,
cap->nchar);
break;
+ case 'm': /* "am" = a matching pair of characters */
+ cap->extra_char = plain_vgetc();
+ flag = current_quote(cap->oap, cap->count1, include,
+ cap->extra_char);
+ break;
#if 0 /* TODO */
case 'S': /* "aS" = a section */
case 'f': /* "af" = a filename */