开发者

Leader mapping to toggle a vim setting

开发者 https://www.devze.com 2023-03-30 20:06 出处:网络
There are several Vim settings I love, but are too annoying to always enable. For example: set开发者_高级运维 relativenumber - annoying when scrolling

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

精彩评论

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