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,
  • 1
    Your question is a bit unclear, but I think set nu sm hls will do what you want? – Martin Tournoij Dec 4 '17 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 Dec 4 '17 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 Dec 4 '17 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. – Christian Brabandt Dec 4 '17 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 Dec 4 '17 at 13:16

I'm not sure why you'd want to do this, and 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.

| improve this answer | |
  • Thank you so muck for clear, so I will use of default and standard option :))) – Cy8099 Dec 4 '17 at 14:59
  • Is it your job to figure out why the OP needs to know something? this can be done with the "|" character, analogous to the pipeline. – Christopher Mar 26 at 14:40

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.