2

When gvim is opened it saves the cursor position whether it is minimized or not. So I'm curious whether it is possible to add a string starting from the cursor blinking position by running a shell script or through a terminal.

1
  • Can you elaborate the question a bit, giving some example? As I'm not clear what's asked exactly.
    – kenorb
    Mar 19 '15 at 11:18
2

Take note of the server name of your GVim window by looking at its title, it should have something like VIM or VIM1.

You can then use this command to insert foo at the current cursor position:

$ vim --servername VIM --remote-send "ifoo<Esc>"

For more information, see :help clientserver.

0

vim -c command lets you specify a command to be executed on the first loaded file.

When last exiting, Vim saved the location of the cursor as the mark named ". The normal-mode command to go to that mark would be '". The ex-command version of that would be :norm '". Once at that location, to insert the string hello, you would use ihello.

$ vim -c "norm '\"ihello" file.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.