So the main problem with your command is that by using |
you're actually breaking it into several commands, the first of which being nnoremap
, but from the second on, a series of silent!
commands with substitutions, which are being run at the time your .vimrc
is being sourced, rather than becoming part of the command.
Using either \|
or <bar>
should solve that.
The second issue is that nnoremap
expects a command in normal mode, so it takes your silent!
and runs the s
(substitute) command, which then replaces the character under the cursor with ilent! ...
, which is not what you want... You need an extra :
before that first silent!
so it knows to go into command mode.
And third, your last command %s/;$<CR>
is not really well formed, you need two additional /
s to complete it. I'm assuming your intention is to strip all ;
s at the end of lines, so %s/;$//
is what I'm assuming you want here. (I also noticed you skipped a silent!
there, maybe by omission? I'm adding it here, just in case.)
Putting it all together:
nnoremap ;; :silent! :%s/\s\+$//e \| silent! :%s/\(\n\n\)\n\+/\1/ \| silent! :%s#\($\n\s*\)\+\%$## \| silent! :%s/;$//<CR>