问题
Without any specific regularity my vim displays underlines on the place of tabs (see below).
Sometimes it also happens to the text: I type and it's underlined.
What could be a reason?

回答1:
This is likely due to the fact that you are editing an html file and the text near the underline is inside of an <a>
tag.
To disable this you can add let html_no_rendering=1
to your ~/.vimrc
. This setting will, however, also disable bold and italic styling for html files.
If you wish to only disable the underlining, see :help html.vim
. There it gives you instructions on what highlight groups you need to redefine without underline
.
回答2:
This method (cobbled from other responses) will enable underline only under the text portion of the link without modifying the full html.vim syntax file.
- Create the file ~/.vim/after/syntax/html.vim
Paste the following into that file:
" disable the current htmlLink syntax highlight link htmlLink text " enable a new htmlLink syntax syn region htmlLink start="<a\>\_[^>]*\<href\>" end="</a>"me=e-4 keepend contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLinkText,javaScript,@htmlPreproc syn match htmlLinkText contained contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLinkText,javaScript,@htmlPreproc "^\s*\zs.\{-}\ze\s*$" syn match htmlLinkText contained contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLinkText,javaScript,@htmlPreproc "\S.\{-}\ze\s*$" " enable the new syntax hi def link htmlLinkText Underlined
回答3:
It's probably one of two things, either:
- You have
'list'
set: (try:set list?
and if this sayslist
, try:set nolist
) - You have some syntax highlighting configuration that highlights tabs as underlined. Add the following mapping, then put the cursor on the tab and press
<F3>
. If it shows a highlighting group, typehi GROUPNAME
to confirm the highlighting (with GROUPNAME replaced by the last named group in angle brackets). Then adjust your colour scheme to get rid of the underline.
Mapping to identify highlight group:
map <F3> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#") . " BG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"bg#")<CR>
来源:https://stackoverflow.com/questions/4625274/why-is-vim-drawing-underlines-on-the-place-of-tabs-and-how-to-avoid-this