Vim - map shell command - Stack Overflow
Note some things:Mapping keys in Vim - Tutorial (Part 1) - Vim Tips Wiki - Wikia
- Don’t use
nore) unless you have a specific reason. I believe you don’t need this mapping for visual and operator-pending modes (leading
nrestricts mapping to normal mode only) and you also should not want this mapping to be remappable.
to discard count you can occasionally type unless you do know you need it (third version uses two hacks that turn mapping to no-op with a side-effect and does not need
- Never forget to escape shell arguments.
- Version with
silent !(do not forget space after
silent, this is why @David Pope’s answer does not work) has
at the end. This is because using
!will always provide access to your terminal and thus redraw is needed after command has run.
- Versions with
system()won’t work if you add an argument containing newline, it is a documented bug. If you don’t want to do so (
expand('won’t ever add newline) it is absolutely safe.
tis a very useful motion. It is better to learn to use it then remap it to something. I suggest
,tas a lhs.
Mapping key sequences
Vim documentation: help
Vim documentation: usr_41
Vim documentation: map
Learn Vimscript the Hard Way