2017-07-10 7 views
2

私は字下げをvimで見えるように、listchars(あるいは必要ならば何らかの種類のプラグイン)を使いたいです。しかし、私は先頭のスペース/タブを表示するだけで、すべてのスペースやタブを表示する必要はありません。vim:先頭の空白/タブのみを表示する

私はスペースのためにhereを発見したちょっとしたハックがあります。コメントにオプションがありますhere。問題は、タブの幅が可変なので、これらのオプションはタブに使用できないということです。最高で、私は>---のような一定の幅の文字列でタブを置き換えることができますが、それは2文字のタブがある場合、インデントが終了することを意味します。

インラインまたはトレーリングタブではなく、先頭のタブのみを表示する方法はありますか?

答えて

2

VIMでは、先頭のスペースと末尾のスペースは区別できますが、先頭のタブまたは末尾のタブは区別できません。つまり、タブはVIMのタブにすぎず、tab:xyで表されます。 space:ctrail:cの両方を定義すると、前者は後続のスペースを除くすべてのスペースを表し、後ろのスペースは後ろのスペースを表します。

     *'listchars'* *'lcs'* 
'listchars' 'lcs' string (default "eol:$") 
      global 
      {not in Vi} 
    Strings to use in 'list' mode and for the |:list| command. It is a 
    comma separated list of string settings. 
          *lcs-eol* 
     eol:c  Character to show at the end of each line. When 
      omitted, there is no extra character at the end of the 
      line. 
          *lcs-tab* 
     tab:xy Two characters to be used to show a tab. The first 
      char is used once. The second char is repeated to 
      fill the space that the tab normally occupies. 
      "tab:>-" will show a tab that takes four spaces as 
      ">---". When omitted, a tab is show as ^I. 
          *lcs-space* 
     space:c Character to show for a space. When omitted, spaces 
      are left blank. 
          *lcs-trail* 
     trail:c Character to show for trailing spaces. When omitted, 
      trailing spaces are blank. Overrides the "space" 
      setting for trailing spaces. 
          *lcs-extends* 
     extends:c Character to show in the last column, when 'wrap' is 
      off and the line continues beyond the right of the 
      screen. 
          *lcs-precedes* 
     precedes:c Character to show in the first column, when 'wrap' 
      is off and there is text preceding the character 
      visible in the first column. 
          *lcs-conceal* 
     conceal:c Character to show in place of concealed text, when 
      'conceallevel' is set to 1. 
          *lcs-nbsp* 
     nbsp:c Character to show for a non-breakable space character 
      (0xA0 (160 decimal) and U+202F). Left blank when 
      omitted. 

    The characters ':' and ',' should not be used. UTF-8 characters can 
    be used when 'encoding' is "utf-8", otherwise only printable 
    characters are allowed. All characters must be single width. 

    Examples: > 
     :set lcs=tab:>-,trail:- 
     :set lcs=tab:>-,eol:<,nbsp:% 
     :set lcs=extends:>,precedes:< 
< The "NonText" highlighting will be used for "eol", "extends" and 
    "precedes". "SpecialKey" for "nbsp", "space", "tab" and "trail". 
    |hl-NonText| |hl-SpecialKey| 

より良いアプローチは、私は本当に強調好きではない、syntaxと同様::

highlight LeadingSpace ctermbg=red guibg=red 
highlight TrailingSpace ctermbg=red guibg=red 
highlight LeadingTab ctermbg=red guibg=green 
highlight TrailingTab ctermbg=red guibg=green 
call matchadd('LeadingSpace', '^\s\+', 80) 
call matchadd('TrailingSpace', '\s\+$', 80) 
call matchadd('LeadingTab', '^t\+', 99)  
call matchadd('TrailingTab', '\t\+$', 99)  
+0

何かをmatchを使用するかもしれません。明るい灰色の文字は、一般的な構文の強調表示と一緒に侵入しにくく、使用可能です。これを使用して、先行しないタブや何かのために 'listchar'を"上書き "する方法はありますか? – ewok

+0

@ewok私はあなたと一緒にいますが、 '' listchat''ではこれはできません。 – Meitham

関連する問題