I have mapped a key shortcut to copy all lines to system clipboard, which is working fine
nnoremap <localleader>o :silent %w !pbcopy<cr>
I would like to display the message as 'Copied' in the status bar. Reading other answers, I found echom
or echo
can be used to display the messages
I have tried below
nnoremap <localleader>o :silent %w !pbcopy<cr>|:echom "Copied"
nnoremap <localleader>o :silent %w !pbcopy<cr>|echom "Copied"
These lines are placed in .vimrc
. It appears lines are getting copied to clipboard, but the message is not being displayed anywhere.
1) How do I display the message from mapped command?
2) On opening a file, I see the 'Copied' message, and a line that says 'Press Enter to continue'. It appears the mapping is being invoked on sourcing the vimrc. The message should not be echoed while sourcing the vimrc file. How do I stop this?
:execute
. But for this specific case, Martin's answer below is really good.