42

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

1 Answer 1

52
$ vim -c 'set ai'

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

9
  • 4
    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, 2018 at 12:32
  • Example I would find useful: vim -c 'set wrap' /path/to/file.txt Jul 22, 2018 at 23:02
  • 2
    If you want to set multiple options, separate them with the pipe character, like vim -c 'set ai | set nowrap'
    – wisbucky
    Jun 24, 2019 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. Jun 28, 2019 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, 2019 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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