Reputation: 4168
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!
Upvotes: 14
Views: 13199
Reputation: 81
it works perfectly well with a unicode vim in a terminal.
Just put it in my vim vundle file:
https://github.com/crux/crux-vimrc/blob/master/plugin/unicode.vim
-nargs=0 Overline call s:CombineSelection(<line1>, <line2>, '0305') command! -range -nargs=0 Underline call s:CombineSelection(<line1>, <line2>, '0332') command! -range -nargs=0 DoubleUnderline call s:CombineSelection(<line1>, <line2>, '0333') command! -range -nargs=0 Strikethrough call s:CombineSelection(<line1>, <line2>, '0336') function! s:CombineSelection(line1, line2, cp) execute 'let char = "\u'.a:cp.'"' execute a:line1.','.a:line2.'s/\%V[^[:cntrl:]]/&'.char.'/ge' endfunction vnoremap :Strikethrough<CR> vnoremap __ :Underline<CR> ```
Upvotes: 3
Reputation: 840
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).
Upvotes: 7
Reputation: 71
You can create a (single) strikethrough character by appending the unicode "long strike overlay combining character" (0336) to the character. For example, to create a strikethrough "Z", enter (in input mode):
Z^Vu0336
(where ^V is CTRL-V).
You can use :s (substitute) to strikethrough a bunch of characters, for example, to strikethrough the current line:
:s/./&^Vu0336/g
Wikipedia links: strikethrough and combining chaaracter.
Upvotes: 7
Reputation: 281
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)
Upvotes: 13
Reputation: 8248
There is a patch pending, to make this work in the gui. Unfortunately, this is currently burried in the todo list, so it will take I while, until it will be applied by Bram.
Upvotes: 1
Reputation: 8356
If you're working with Unicode text, you may be able to achieve this using combining characters. The following article describes how this can be accomplished in gvim:
You will need to make sure that the font gvim is using supports the appropriate characters, on Windows both Consolas
and Courier New
appeared to handle this correctly, but most of the others did not.
Upvotes: 21
Reputation: 11028
If you are using Vim under a terminal, no you can't.
highlight arguments for normal terminals
*bold* *underline* *undercurl* *inverse* *italic* *standout*
term={attr-list} attr-list *highlight-term* E418 attr-list is a comma separated list (without spaces) of the following items (in any order): bold underline undercurl not always available reverse inverse same as reverse italic standout NONE no attributes used (used to reset it)
Note that "bold" can be used here and by using a bold font. They have the same effect. "undercurl" is a curly underline. When "undercurl" is not possible then "underline" is used. In general "undercurl" is only available in the GUI. The color is set with |highlight-guisp|. ~
However, under GUI, you can do so. Under 'guifont'
, we have the following:
For the Win32 GUI *E244* *E245* - takes these options in the font name: hXX - height is XX (points, can be floating-point) wXX - width is XX (points, can be floating-point) b - bold i - italic u - underline s - strikeout cXX - character set XX. Valid charsets are: ANSI, ARABIC, BALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK, HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS, SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC. Normally you would use "cDEFAULT". Use a ':' to separate the options. - A '_' can be used in the place of a space, so you don't need to use backslashes to escape the spaces. - Examples: > :set guifont=courier_new:h12:w5:b:cRUSSIAN :set guifont=Andale_Mono:h7.5:w4.5
Upvotes: -7
Reputation: 609
no, vim doesn't support this. it's a text editor, not a WYSIWYG editor.
Upvotes: -4