Saturday, April 18, 2015

Re: grepping substitute commands from file into current buffer

I guess the visual bell trashes a mapping, and I couldn't find any way to have vim ignore it (set vb t_vb="" just stops it flashing I guess), so I've removed the pl sequence and used a while loop for that process and all is now well.

On Sat, Apr 18, 2015 at 9:46 AM, Graham Lawrence <gl00637@gmail.com> wrote:
As my typical use of vim is applying the substitute command, I decided to maintain a file of previously used such commands, and to grep a selection of them back into my current buffer by providing grep with the first few characters of the pattern for the substitute I wish to make.  For that, I have produced this mapping:
" grep pattern from subs.vim into current buffer  imap <S-F8> \<Esc>xbPlplplplplp:s/\\*$//<CR>d$:r!grep " ^R"" subs.vim<CR>  
Note ^R is the blue text produced by the sequence ^V^R

The imap RHS works as expected if run by hand as ex commands, but fails as a mapping because one superfluous \ (inserted by the plplp sequence) remains after the substitute that should remove them all.
e.g. the sequence /\([ is converted to \/\\\(\[\ instead of the required \/\\\(\[

I have also tried pasting the \s from right to left and stripped superfluous \ from the front end of the line, but got a similar result.  Any suggestions as to why this happens?

--
Graham Lawrence



--
Graham Lawrence

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: