r/vim•
awhead

How do I "break" in an if/endif block in the vimrc file?

I have a vimrc file the top of which is this code block:

if &diff
    colorscheme molokai
endif
" loads of other stuff

If I do vimdiff, I don't want any of the "loads of other stuff" to run so I want to put a break after the > colorscheme molokai < line. How do I do this? Thanks

Posted Aug 22, 2018, 5:24 PM UTC

05
jdw96•

Usually a "break" is used to exit a loop. It sounds more like you want an "else" clause. That should look like this:

if &diff
    colorscheme molokai
else
    " loads of other stuff
endif
9
awheadOP•

damn i feel stupid

of course

5
arp242I use arrow keys and tabs as buffers. I'm not ashamed of it•

You can use finish, which is Vim's version of exit 0. See :help finish:

if &diff
    colorscheme molokai
    finish
endif
" loads of other stuff
7
awheadOP•

yes this is exactly what i was looking for "finish"

TYVM!

3
jdw96•

I didn't know finish existed, but that's definitely better than my answer of else.

1
[deleted]•

[deleted]

1
[deleted]•

[deleted]

1