Vim Column Switch

When characters are defined in Vim, a column appears on the left side of the screen.

From Vim Help:

When characters are defined for a file, Vim will automatically add a column of two character files to display them. When the last character is not set, the column
disappears again.

Is it possible to delete a column while there are still certain characters?

Ideally, I would like to turn on / off the column.

+4
source share
4 answers

Well, you need to replace all characters for the current buffer so that they do not appear. In recent Vims (e.g. newer than 7.3.596) you can simply use :sign unplace * .

You can take my plugin https://github.com/chrisbra/SaveSigns.vim to save these characters in a temporary file (which will actually create a Vim script to be able to replace all characters. Using this plugin, you can write a custom function to switch displayed characters.

Something like this might work for you:

 fu! MySignsToggle() if !has("signs") || empty(bufname('')) return endif if !exists("s:signfile") let s:signfile = tempname().'_' endif redir =>a|exe "sil sign place buffer=".bufnr('')|redir end let signs = split(a, "\n")[1:] if !empty(signs) let bufnr = bufnr('') exe ":sil SaveSigns!" s:signfile.bufnr('') if bufnr('') != bufnr exe "noa wq" endif sign unplace * elseif filereadable(s:signfile.bufnr('')) exe "so" s:signfile.bufnr('') call delete(s:signfile.bufnr('')) endif endfu 
+7
source

If you are ready to wait until Bram gets it on his TODO list or wants to fix / compile Vim, a patch has recently been added to allow this with the new "signcolumn" option. https://groups.google.com/d/topic/vim_dev/CrBId6DRbvo/discussion

+3
source

Well, you distinguish between certain (describes how a certain character looks) and placed signs (which are actually shown in the sign column).

Unfortunately, there is no way to switch the character column without first deleting all the marked characters. Thus, you will need to use the / dict list to store identifiers / line numbers of characters.

(Shameless plugin: https://github.com/mhinz/vim-signify )

+2
source

If you are using Vim 8.0 or later (or NeoVim), now this is a simple setup:

 $ vim "+help signcolumn" "+only" 

For instance,

 :set scl=no " force the signcolumn to disappear :set scl=yes " force the signcolumn to appear :set scl=auto " return the signcolumn to the default behaviour 
+2
source

Source: https://habr.com/ru/post/1497854/


All Articles