Skip to main content

You could use ex, which comes with vim and is the command line tool for vim.

Eran's answer is definitely correct, but I'd personally use ex -c (vim -c is also possible):

> echo asdf > blub
> ex fileblub -c "normal a_" -c "normal l.l.l." -c wq
> cat blub
a_s_d_f_

This is my preferred way, because there are not multiple files.

If you remap escape to jj (for example), you can easily make more complicated normal statements:

ex file -c "normal a_jjl.l.l." -c wq

For your information:

  • normal sends letters in normal mode to
  • wq quits the program
  • to send multiple commands in one string (no additional -c option), use the pipe character |. But: This does not work in the case of normal.
  • This works only for 10 -c's. But for more commands, I would recommend to create a file.

You could use ex, which comes with vim and is the command line tool for vim.

Eran's answer is definitely correct, but I'd personally use ex -c (vim -c is also possible):

> echo asdf > blub
> ex file -c "normal a_" -c "normal l.l.l." -c wq
> cat blub
a_s_d_f_

This is my preferred way, because there are not multiple files.

If you remap escape to jj (for example), you can easily make more complicated normal statements:

ex file -c "normal a_jjl.l.l." -c wq

For your information:

  • normal sends letters in normal mode to
  • wq quits the program
  • to send multiple commands in one string (no additional -c option), use the pipe character |. But: This does not work in the case of normal.
  • This works only for 10 -c's. But for more commands, I would recommend to create a file.

You could use ex, which comes with vim and is the command line tool for vim.

Eran's answer is definitely correct, but I'd personally use ex -c (vim -c is also possible):

> echo asdf > blub
> ex blub -c "normal a_" -c "normal l.l.l." -c wq
> cat blub
a_s_d_f_

This is my preferred way, because there are not multiple files.

If you remap escape to jj (for example), you can easily make more complicated normal statements:

ex file -c "normal a_jjl.l.l." -c wq

For your information:

  • normal sends letters in normal mode to
  • wq quits the program
  • to send multiple commands in one string (no additional -c option), use the pipe character |. But: This does not work in the case of normal.
  • This works only for 10 -c's. But for more commands, I would recommend to create a file.
added 4 characters in body
Source Link
Stéphane Gimenez
  • 29.4k
  • 3
  • 79
  • 88

You could use "ex"ex, which comes with vim and is the command line tool for vim.

Eran's answer is definitely correct, but I'd personally use ex -cex -c (vim -cvim -c is also possible):

> echo asdf > blub
> ex file -c "normal a_" -c "normal l.l.l." -c wq
> cat blub
a_s_d_f_

This is my preferred way, because there are not multiple files.

If you remap escape to jj (for example), you can easily make more complicated normal statements: > ex file -c "normal a_jjl.l.l." -c wq

ex file -c "normal a_jjl.l.l." -c wq

For your information:

  • normal sends letters in normal mode to
  • wq quits the program
  • to send multiple commands in one string (no additional -c option), use the pipe character |. But: This does not work in the case of normal.
  • This works only for 10 -c's. But for more commands, I would recommend to create a file.

You could use "ex", which comes with vim and is the command line tool for vim.

Eran's answer is definitely correct, but I'd personally use ex -c (vim -c is also possible):

> echo asdf > blub
> ex file -c "normal a_" -c "normal l.l.l." -c wq
> cat blub
a_s_d_f_

This is my preferred way, because there are not multiple files.

If you remap escape to jj (for example), you can easily make more complicated normal statements: > ex file -c "normal a_jjl.l.l." -c wq

For your information:

  • normal sends letters in normal mode to
  • wq quits the program
  • to send multiple commands in one string (no additional -c option), use the pipe character |. But: This does not work in the case of normal.
  • This works only for 10 -c's. But for more commands, I would recommend to create a file.

You could use ex, which comes with vim and is the command line tool for vim.

Eran's answer is definitely correct, but I'd personally use ex -c (vim -c is also possible):

> echo asdf > blub
> ex file -c "normal a_" -c "normal l.l.l." -c wq
> cat blub
a_s_d_f_

This is my preferred way, because there are not multiple files.

If you remap escape to jj (for example), you can easily make more complicated normal statements:

ex file -c "normal a_jjl.l.l." -c wq

For your information:

  • normal sends letters in normal mode to
  • wq quits the program
  • to send multiple commands in one string (no additional -c option), use the pipe character |. But: This does not work in the case of normal.
  • This works only for 10 -c's. But for more commands, I would recommend to create a file.
Source Link

You could use "ex", which comes with vim and is the command line tool for vim.

Eran's answer is definitely correct, but I'd personally use ex -c (vim -c is also possible):

> echo asdf > blub
> ex file -c "normal a_" -c "normal l.l.l." -c wq
> cat blub
a_s_d_f_

This is my preferred way, because there are not multiple files.

If you remap escape to jj (for example), you can easily make more complicated normal statements: > ex file -c "normal a_jjl.l.l." -c wq

For your information:

  • normal sends letters in normal mode to
  • wq quits the program
  • to send multiple commands in one string (no additional -c option), use the pipe character |. But: This does not work in the case of normal.
  • This works only for 10 -c's. But for more commands, I would recommend to create a file.