How to run shell command through vimscript?

In my Vim setup, I would like to add a configuration that runs a shell command with a specific mapping. Is there any way to do this in vimscript?

+6
source share
2 answers

There is a system() function in vim , try the following:

 :call system('date') 
+7
source

I am doing this with traditional vi, so I assume that it will work with vim as well.

In my .exrc, I have:

 map ^_ !}fmt 71 72^M 

(To enter ^_ by typing ctrl-V ctrl -_ and ^M by typing ctrl-V ctrl-M

When I hit ctrl -_ in vi, it reformatts my current line to 72 characters.

+3
source

Source: https://habr.com/ru/post/916739/


All Articles