26

How does one set a vim option when launching from bash or another shell?

34
$ vim -c 'set ai'

See :h -c, :h startup and $ vim --help.

  • 2
    If you intend to open multiple windows (vim -O or vim -o) and want to set this command for all of them, use -c windo <option>. Example: vim -O -c 'windo set ai'). – scai Apr 13 '18 at 12:32
  • Example I would find useful: vim -c 'set wrap' /path/to/file.txt – Sridhar Sarnobat Jul 22 '18 at 23:02
  • If you want to set multiple options, separate them with the pipe character, like vim -c 'set ai | set nowrap' – wisbucky Jun 24 at 22:48
  • 1
    Does set ai nowrap not work for you @wisbucky? You should be able to set multiple options with a single set command. – Martin Tournoij Jun 28 at 14:07
  • @MartinTournoij Thanks, I didn't know about that! (Well, I guess my comment can still be helpful if you need to run different commands) – wisbucky Jun 28 at 20:14

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.