My Vim config includes plugins that try to handle current project, build tags, etc. This is quite useful for my daily programming in Vim, but it's just annoying when I use Vim for some quick edits, like:
- edit a git commit message;
- edit a shell command when I type Ctrl+xCtrl+e in zsh or bash;
- etc.
I don't like the --noplugins
either, since I still want to take advantage of some plugins in quick-edit mode, such as surround, easy-motion, and lots of others.
So, I want to have some "light mode" (or "quick mode"), in which some of the plugins will be bypassed, but not all of them.
My first idea was to have some special command-line argument, which I'd parse in vimscript, but quick googling shows that it's currently impossible in vimscript (awful sad, by the way).
My second idea is to set some environment variable when running vim, like this:
$ VIM_LIGHT_MODE=1 vim
This works in git:
$ git config --global core.editor 'VIM_LIGHT_MODE=1 vim'
But if I do EDITOR='VIM_LIGHT_MODE=1 vim'
, and type Ctrl+xCtrl+e in the shell, it doesn't work:
edit-command-line:13: command not found: VIM_LIGHT_MODE=1
Then I tried this: EDITOR="bash -c 'VIM_LIGHT_MODE=1 vim'"
, but it fails as well:
vim': -c: line 1: syntax error: unexpected end of file
(To be honest, this one looks particularly weird, it seems I misunderstand how exactly $EDITOR
is used, and I'll be glad if someone explains what's going on here)
All other experiments failed as well.
The only hack I can think of is to set some servername
, like:
$ vim --servername VIM_LIGHTWEIGHT_MODE
And then check v:servername
in vimscript, but this is a total hack: this is not what servername is for, at all.
So is there a cleaner way to achieve what I want?
env
:EDITOR='env VIM_LIGHT_MODE=1 vim'
.vim
asvim -u .vimrc-light
.env
at all, my shell-fu is still too weak. Consider writing it as an answer, so that I'll be able to accept it.