开发者

Leader mapping to toggle a vim setting

There are several Vim settings I love, but are too annoying to always enable. For example:

  • set开发者_高级运维 relativenumber - annoying when scrolling
  • set 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜