I have the following mapping in my ~/.vimrc
file:
map <F3> my0v$"+y`y
It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any suggestions?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityYou have options:
:echo
at the end of your mapping. map <key> foo:echo "done"<cr>
'showcmd'
which will show partial commands. This will give you a slight clue that something happened for multi-key mappings/commands. (Not really helpful here)General rule of thumbs for mappings:
nmap
for normal mode*noremap
variants unless you want remapping to occur or using a <Plug>
mappingThis means your mapping would look like:
nnoremap <F3> my0v$"+y`y
Some more thoughts:
"+yy
/"+Y
, :yank +
, or V"+y
. There is another newline in the register, but that is easy to reason about.g_
instead of $
.y
mark. This could be surprising, consider using a :yank
or yy
/Y
nnoremap <f3> "+yy:call setreg('+', @+, 'v')<cr>
Personally, I lean toward using vim-highlightyank and the following mapping:
nnoremap <silent> <f3> "+yy:call setreg('+', @+, 'v')<cr>
map <F3> "+yy
?yy
/Y
or:yank
and just accept to do a little cleanup on paste/put.