Vim line numbers, absolute within visual mode and relative within insert

天大地大妈咪最大 提交于 2020-01-06 14:26:11

问题


I have line numbers set within my .vimrc.

I'm wanting to switch to relativenumbers when in insert mode, and switch back to regular numbers in visual mode.

I've tried:

autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber

But this isn't working. I'm using Vim7.4.52 in terminal, Ubuntu.

If possible I want to do this automatically, so I haven't got to fiddle with manually entering a command.


回答1:


number and relativenumber setting are not exclusive anymore, so rather use something like this:

autocmd InsertEnter * :set nonumber relativenumber autocmd InsertLeave * :set number norelativenumber

Or use one of the many plugins, that do that (sorry, I don't remember which ones do that).



来源:https://stackoverflow.com/questions/37612914/vim-line-numbers-absolute-within-visual-mode-and-relative-within-insert

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!