> I tried to use :g/abc/insert\ etc. just like in the help, and I always get
> "E488 - Trailing characters".  Do I have some setting wrong?

The problem seems to reside with the ":insert" continuation as 
other commands work just fine.  I found the example that looks 
like yours at

   :help :insert

(would have helped if you had included _where_ in the help your 
"just like in the help" came from, as the help is huge :)


   When these commands are used with :global or :vglobal
   then the lines are obtained from the text following the
   command.  Separate lines with a NL escaped with a
   backslash:
     :global/abc/insert\
     one line\
     another line
   The final "." is not needed then.

Typing that example verbatim does fail in the way you describe. 
This looks like an error in the help or an error in :insert  (at 
least from Vim6.2 onward, which is the oldest version I have on 
hand for testing).  Just to be sure, I also tried copying the 
example into a script and sourcing it.  Same error.

As a work around, you can yank the text you wish to insert and 
then use

   " scratch register
   :g/abc/put
   " put the contents of register "b"
   :g/abc/put b

to put the text afterwards.  Or, if you want to use a variable to 
hold the instead of tromping a register:

   :g/abc/put=my_variable_name

Peculiarly, the "put =" notation treats double-quotes as comment 
delimiters which means to put in a raw string with newlines, you 
have to use

   :g/abc/put=\"one\ntwo\nthree\"

escaping the double-quotes.  (Using single quotes prevents 
treatment of the "\n" as a newline; tried with various 
alternatives such as ^J, ^M, ^V^J, ^V^M, and \r but none of them 
worked within single-quoted strings)

Hope this helps (1) confirm that you're not crazy and (2) gets 
you a workaround to accomplish a similar behavior.

-tim



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to