Denis Perelyubskiy wrote:
hello,
I am trying to emulate textpad. In textpad, when cursor is over some
word and you press ctrl-f5 the search box pops up, and a word is in the
input area.
So, an equivalent behavior (at least for now :-)) in vim is to press
ctrl-f5 and have a word show up in the string
:vimgrep/WORD/j c:/projects/foo/**/*.[ch]
I know how to do this in a kludgy way, by yanking the word with viwy.
However, that "kills" the * register. The question is whether it is
possible to do what i want through some temp register, without "killing"
the * (or using the * and then restoring it):
It only kills the * register (the clipboard) if you have ":set
clipboard=unnamed". Otherwise it clobbers only registers " (the
"unnamed" or default register) and 0 (the "last yank" register). You can
yank into any other register of your choice (usually a to z but there
are a few other "special-purpose" registers) by prefixing the y of the
yank command with "x where x is the one-character register name: for
instance,
viw"zy
uses register z (rather than the unnamed register and, with
"clipboard=unnamed", the clipboard) for the yank.
You can also access any register as a variable by prefixing its
one-character name with an at-sign as in
:let save_clipboard = @*
or
:let @* = save_clipboard
In Insert/Replace and Command-line modes, you can also insert any
register's contents by means of Ctrl-R followed by the register's name:
for instance, Ctrl-R / (or, in a mapping, <C-R>/ ) inserts the latest
search pattern.
see ":help copy-move" and read all of section 5, i.e., until the
horizontal separation before "6. Formatting text".
I could map ctrl f5 to something like (kludgy):
nmap <C-F5> <ESC>viwy:vimgrep/<S-Insert>/j c:/projects/kopera/**/*.[ch]
map! <C-F5> <ESC>viwy:vimgrep/<S-Insert>/j c:/projects/kopera/**/*.[ch]
There must be a prettier way of doing that (and a way which does not
kill the *)
Could someone please point me to the right direction?
thanks,
denis
Best regards,
Tony.