Re: How to yank a searched string
- Thanks for your very detailed explanation, Andy. Now it is clear for
me, how it works. Specially thanks for observation, that remapped n
and N commands are always searches only one direction. This is
important, because it differs from default behavior, and this
information is missing in the tip.
2008/9/6, Andy Wokula <anwoku@...>:
> Anton Sharonov schrieb:
>> Thanks for explanation, Andy ! I have just learned new amazing
>> c//e "change match hit" command. Only the problem with it, I
>> can't consistently apply my favorite use-case pattern "n.n.n." to
>> it. One should always restart search explicitly using //<CR>
>> rather than just use n after pressing "." :(
> n.n.n. ... also one of my favorite combos. In my vimrc, I map n to
> //<CR> and N to ??<CR> and it works ok for me (for quite a long
> no <script> n //<cr><sid>histdel
> sunmap n
> no <script> N ??<cr><sid>histdel
> sunmap N
> nn <silent> <sid>histdel :call<sid>histdel(0)<cr>
> vn <silent> <sid>histdel :<c-u>call<sid>histdel(1)<cr>
> func! <sid>histdel(vmode)
> if a:vmode
> normal! gv
> call histdel('/', -1)
> It contains additional code: Searching for "/" or "?" adds a garbage
> entry to the history, which is removed with <sid>histdel. Actually, the
> entry doesn't hurt, but I often use "/<C-P>" to modify the last pattern,
> and then the entry becomes a little annoying.
> I even like that now n always searches forward (e.g. after ?pat<CR> )
> and N always backward. Only in very few cases, I really want to
> repeat a search for /pat/e . Then I simply unmap n .
> The main mappings:
> ono m //e<cr>
> xn <script> m //e<sid>seloff<cr>
> cno <expr> <sid>seloff &sel=="exclusive" ? "+1" : ""
> In the Vimtip, the s key is mapped, but I'm used to press s to
> change the visual selection. Here I choose m , which isn't perfect
> too, because it can be used to set a mark from Visual mode, but I almost
> never do that. Rather, m as a mnemonic reminds of "match" in "end of
> match" (with "match" at the end of the "end of match" sequence ;-), and
> on the keyboard M is placed right next to N, and even to be typed with
> the same finger.
> The <sid>seloff mapping is a late addition inspired by the Vimtip, I
> think I'm going to remove it, because I always use 'sel=inclusive'.
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php