I am trying to copy Vim's buffer to clipboard and I did the following:
:!cat %|pbcopy
# It works perfectly
Then I tried to map this with the leader key (its my first attempt to map something, so please excuse if something silly is found).
:map <leader>c :!cat %|pbcopy
# This is not working; vim complains: Not an Editor command
Escape the pipe
Also consider using nnoremap to stop recursive mappings and ending the command with
<CR>
so the command runs automatically.You also might consider using shellescape just incase the file has spaces or other unusual characters
Or as Peter Rickner says just use