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) When opening a file, before Vim actually opens, I see the 'Copied' message, and a line that says 'Press Enter to continue' in the terminal. 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?

1 Answer 1


Once you have run an ex command, you can immediately press : again to enter another one.

Similarly, after <CR>, you can follow up with :another command<CR> with no need for | or anything else in between.

nnoremap <localleader>o :silent %w !pbcopy<cr>:echom "Copied"<CR>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .