How to run Vim commands from a terminal

My questions are a question that I have not seen, a common question is how to run certain commands in a file.

My question is how to run Vim commands or functions from outside Vim (i.e. the terminal), this will not affect any file, just Vim. Is it possible? If so, how?

If this is not possible, like this, is there a way to enter Vim, run the command automatically, and then exit when it ends? Or run another command and then exit it?

Thank you for your help!

+4
source share
1 answer

Using

vim --cmd 'Command launched before vimrc' \ -c 'Command launched after vimrc' \ -c 'qa!' # Quit vim 

. To run a command in an existing vim session, you need to use the + clientserver function: start one vim with

 vim --servername vim 

and others with

 vim --remote-send '<C-\><Cn>:Command<CR>' 
+10
source

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


All Articles