2009-06-26 4 views
0

orを使ってカーソルの下の単語を得ることができ、それを使ってファイルを開き、argリストに追加することができます。たとえば、45行のJavaクラス名の上にカーソルを持つ:、^]とargeをどのように組み合わせてタグに従い、argリストに追加するのですか?

:arge +45 mydirhere/<cword>.java 

しかし、私は、タグ・メカニズムに渡す方法がわからないので、それはファイル名(と行数)を返します。 、それはに渡すことができますarge

私の質問は具体的にだと思います: "どのようにタグのメカニズムを呼び出しますか?

String getFileAndLineforTag(String tag) 

答えて

1

あなたはtaglist()機能を使用することができます。私のような何かを期待しています。 :help taglist()から(Vimの7.1で):カスタムコマンドを定義するとき

taglist({expr})       *taglist()* 
     Returns a list of tags matching the regular expression {expr}. 
     Each list item is a dictionary with at least the following 
     entries: 
      name  Name of the tag. 
      filename Name of the file where the tag is 
        defined. It is either relative to the 
        current directory or a full path. 
      cmd  Ex command used to locate the tag in 
        the file. 
      kind  Type of the tag. The value for this 
        entry depends on the language specific 
        kind values. Only available when 
        using a tags file generated by 
        Exuberant ctags or hdrtag. 
      static  A file specific tag. Refer to 
        |static-tag| for more information. 
     More entries may be present, depending on the content of the 
     tags file: access, implementation, inherits and signature. 
     Refer to the ctags documentation for information about these 
     fields. For C code the fields "struct", "class" and "enum" 
     may appear, they give the name of the entity the tag is 
     contained in. 

     The ex-command 'cmd' can be either an ex search pattern, a 
     line number or a line number followed by a byte number. 

     If there are no matching tags, then an empty list is returned. 

     To get an exact tag match, the anchors '^' and '$' should be 
     used in {expr}. Refer to |tag-regexp| for more information 
     about the tag search regular expression pattern. 

     Refer to |'tags'| for information about how the tags file is 
     located by Vim. Refer to |tags-file-format| for the format of 
     the tags file generated by the different ctags tools. 

あなたは-complete =タグや -complete=tag_listfilesを指定することができます。あなたがもっと精巧な何かをする必要があるなら、-complete=custom,{func}または-complete=customlist,{func}を使うことができます。詳細については、:help :command-completionを参照してください。

+0

exe "arge"で終了しました。タグリスト(expand( ""))[0] .filename "ありがとう! – 13ren

0

ローレンス・ゴンサルベスの答えを使用して、右の行に行かない(ありがとう!)

:exe "arge " . taglist(expand("<cword>"))[0].filename 

紛らわしい部分がある、機能と通常のコマンドの世界を統合する方法でしたが、ここでそれを行うにはいくつかのコードです( "exe")とストリングconcatention( ".")

関連する問題