📜 ⬆️ ⬇️

Setting indent inheritance for long lines

It's about how vim "collapses" (does what in English is called wrap) long lines. Suppose you have a very long line of code that begins with some indentation. Most likely, if you use :set wrap and :set showbreak=-> , it looks like this:

 Not-indented line
	 Once indented line
		 Twice indented line, which is long enough
 -> to be wrapped. 


And I would like it to look like this:
')
 Not-indented line
	 Once indented line
		 Twice indented line, which is long enough 
		 -> to be wrapped. 


Unfortunately, it is impossible to achieve this with standard Vim tools, but there is a patch that allows you to cope with it.



The patch is called breakindent patch and can be downloaded at retracile.net/wiki/VimBreakIndent . He patches the vim sources, of which the latter will have to be collected with his own hands. Sources are taken from www.vim.org , Download section. The patch should be applied in the directory where the sources are unpacked, with the command

patch -p1 <file.of.patch

In the implementation I downloaded yesterday, file.of.patch should have been replaced with vim-7.3.285-breakindent.patch .

Further concerns only the assembly of vim from source codes and should not cause problems. If the reader’s hands grow from the same place, from where he and the author of these lines, and he never collected anything from the sources, then the following should be done.

In the src/Makefile file, you can uncomment (removing # at the beginning of the line) the desired options. I would recommend to collect vim in the largest configuration, for which you need to delete the comment character at the beginning of the line

CONF_OPT_FEAT = --with-features=huge

If you need a graphical interface (I would not recommend it, but for taste and color), you need to add the --enable-gui key to the CONF_ARGS line and uncomment one of the CONF_OPT_GUI lines, depending on what you want to have, for example
CONF_ARGS = --exec-prefix=/usr --enable-gui
CONF_OPT_GUI = --enable-gui=gnome2


After all this, it is enough to do (we assume that those for whom such an instruction is useful are in the sudo system)
make
sudo make install

and enjoy the correct indents by issuing the command :set breakindent .

Just in case, information about the folding of lines can be found at :h wrap; :h linebreak; :h showbreak :h wrap; :h linebreak; :h showbreak :h wrap; :h linebreak; :h showbreak . Information that has been reviewed can be searched for on the site vim.wikia.com, where there is a lot of useful information, in particular, vim.wikia.com/wiki/Word_wrap_without_line_breaks .

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


All Articles