Vim cli

From wikinotes

Documentation

:help starting https://vimhelp.org/starting.txt.html

Useful Params

vim -p a b c  # open in new tabs
vim -o a b c  # open in vert splits
vim -O a b c  # open in horiz splits

vim --cmd "let foo=bar" --cmd "let bar=baz"  # run commands before reading vimrc
vim -c "echo foo" -c "echo bar"              # run commands after reading vimrc, and first file

vim '+/[0-9] foo' file.txt                    # open at first line matching regex

You can also pass a script-file in of vim-commands

vim -s <(cat <<EOF
:echom 'hi'
:messages

:function DoThing()
  echom 'bye'
endfunc
EOF
)