10

Is there any way to set options typed on multiple lines with a single :set command?

Here is a part of my vimrc:

se nu
se sm
se hls

And as you see, I have se on every line in which I set an option. I know that I can set the all options in one line with a single se but How can I set them with one se but with the options themselves specified on multiple lines.

e.g. I'd like to write something like:

se nu,
sm,
hls,
5
  • 2
    Your question is a bit unclear, but I think set nu sm hls will do what you want? Commented Dec 4, 2017 at 12:18
  • @Carpetsmoker I think the question is to add a newline between nu and sm and between sm and hls in your command which is (I think) not possible (but I don't really understand how that would be helpful to be able to do that)
    – statox
    Commented Dec 4, 2017 at 12:25
  • no actually I know that I can set these option in one line but I want to set them in some lines with one 'se'.
    – Cy8099
    Commented Dec 4, 2017 at 12:38
  • 2
    I wouldn't recommend it, but it should be possible using \ at the beginning of the lines for line continuation (this depends on the C in cpoptions). Note, this is hardly readable, and using the short option form is not really recommended. Commented Dec 4, 2017 at 12:52
  • Thanks for respon. How about 'ino' & 'cnorea' options? 'cause I have many lines (about 15) that they contain this two options on start of line, Can I sum them up? or Is it good idea to sum up them?
    – Cy8099
    Commented Dec 4, 2017 at 13:16

1 Answer 1

12

I'd personally recommend against doing so, but you can use Vim's "line continuation" feature for this:

set number
\ showmatch
\ hlsearch

This will be interpreted by Vim as if the contents of the lines after the backslashes were written at the end of the previous line:

set number showmatch hlsearch

Note that whitespace before the backslash is ignored:

set number
  \ showmatch
  \ hlsearch

See :help line-continuation for more details.

ino and cnorea are the short forms of the inoremap and cnoreabbrev commands. It is not possible to merge multiple map/abbreviation commands into a single command in this way: this only works with :set because that command already allows you to set multiple options with a single command.

1
  • Thank you so muck for clear, so I will use of default and standard option :)))
    – Cy8099
    Commented Dec 4, 2017 at 14:59

Your Answer

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

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