There are several Vim settings I love, but are too annoying to always enable. For example:
set开发者_高级运维 relativenumber
- annoying when scrollingset list
- distracting when you don't need it
What is a concise leader mapping to toggle a generic Vim setting?
You have two ways, as described in the help:
:set-! :set-inv
:se[t] {option}! or
:se[t] inv{option} Toggle option: Invert value. {not in Vi}
Either
:set list!
Or
:set invlist
Will do the same.
Toggle options by appending !
to :set <option>
For example, to toggle relativenumber
:
nnoremap <leader>r :set relativenumber!<cr>
精彩评论