Why is vim drawing underlines on the place of tabs and how to avoid this?

前端 未结 3 1766
有刺的猬
有刺的猬 2020-12-06 00:46

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.

相关标签:
3条回答
  • 2020-12-06 01:15

    It's probably one of two things, either:

    • You have 'list' set: (try :set list? and if this says list, 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, type hi 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>
    
    0 讨论(0)
  • 2020-12-06 01:27

    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.

    1. Create the file ~/.vim/after/syntax/html.vim
    2. 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
      
    0 讨论(0)
  • 2020-12-06 01:32

    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.

    0 讨论(0)
提交回复
热议问题