In my Vim setup I'd like to add a configuration that runs a shell command with a certain mapping. Is there any possible way to do this in Vimscript?
There is a system() function in vim,try this:
:call system('date')
I do this with traditional vi, so I assume it would work with vim as well.
In my .exrc I have:
map ^_ !}fmt 71 72^M
(That's a ^_ entered by typing ctrl-V ctrl-_, and a ^M entered by typing ctrl-V ctrl-M
When I hit ctrl-_ in vi, it reformats my current line to 72 characters.
来源:https://stackoverflow.com/questions/10766033/how-to-run-a-shell-command-through-vimscript