Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strikeout text in vim?

Tags:

vim

vi

macvim

Does Vim (with or without a plugin - I don't care) support strikethrough text at all? I've found myself keeping a running list of "TO-DO's" in it, and would like to be able to "cross off" my done items, via strikethrough text.

Thanks!

like image 418
Connor Avatar asked Dec 13 '11 00:12

Connor


2 Answers

You can put this in your .vimrc

map _ a<C-V>u0336<Esc><Space>

and then the underscore character will "strikout-ize" whatever is under the cursor, analogous to how ~ (tilde) changes the case.

It works like this:

a - starts to append after the character under the cursor
<C-V>u0336 (stands for Control-V followed by u0336) - the strikout overlay combining character
<Esc> - exists append mode
<Space> - advances the cursor past the strikeout character

Vim assigns another meaning to the Underscore (_) character (see :help _) so you might want to choose another character (or sequence of multiple characters).

like image 69
jimav Avatar answered Sep 18 '22 19:09

jimav


Going for a highlighting simpler solution, I would use a Vim custom syntax highlighting rule so that, for example, text marked like this:

~~ text ~~

is displayed in a different color (eg. a darker text color if you have a dark background, or as dark reversed colors). Which would be, in vimrc:

au BufRead,BufNewFile *.txt   syntax match StrikeoutMatch /\~\~.*\~\~/   
hi def  StrikeoutColor   ctermbg=darkblue ctermfg=black    guibg=darkblue guifg=blue
hi link StrikeoutMatch StrikeoutColor

(where the au command is used to apply the rule to filetype .txt files only)

like image 34
Giovanni Maggiorani Avatar answered Sep 18 '22 19:09

Giovanni Maggiorani