Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Vim - Highlight OverLength


Add the following code to /etc/vimrc if we want to highlight the characters that go beyond column 80.
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+ 

Vim - Change case

Open the document in vim, press v and move to select text and then press one of the following:

U - converts to upper case
u - converts to lower case
~ - toggles the case of selected

To change text of entire file to lower case run the following
ggVGu
replace u with U for uppercase and ~ to toggle.

Vim - Replace with incremental value

:let @a=1 | %s/<old_word>/\='<new_word>'.(@a+setreg('a',@a+1))/g

If the <old_word> is replaced with abc
and <new_word> with xyz

:let @a=1 | %s/abc/\='xyz'.(@a+setreg('a',@a+1))/g

The command will replace all abc with xyz.<number>. The <number> will start with 1 and increment by 1.

1st abc will be replace by xyz.1
2nd abc will be replace by xyz.2
.
.
.
so on