I like to keep a strict 70 character margin whenever possible. To help with this, I want to configure vim so that the 70th character of the current line is highlighted. I understand that
set cursorline
can be used to highlight the current line. I, however, would like just the very end of the line (the 70th character) to be highlighted. How would I go about accomplishing this?
Edit: cursorcolumn isn't what I'm looking for. I just want a single character (the 70th one on the current line).
Edit 2: perhaps a picture will help.
Press the v key to enter visual character mode. The word VISUAL will appear at the bottom of the screen. Use the Arrow keys to highlight the desired text. You can use other navigation commands, such as w to highlight to the beginning of the next word or $ to include the rest of the line.
If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor. Finally, you can select text in columns by pressing ctrl+v and moving up or down the block.
You can use colorcolumn
to set a "right margin" bar.
This did not exist before Vim 7.3, so it is wisest to only enable it if the feature is available.
if exists('&colorcolumn')
set colorcolumn=70
endif
I prefer that this only be shown in insert mode, so I use this:
if exists('&colorcolumn')
autocmd InsertEnter * set colorcolumn=80
autocmd InsertLeave * set colorcolumn=""
endif
That will set the option when you switch to insert mode, and turn it off when you leave insert mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With