标签: tagbar

打开某些文件类型时启动VIM Tagbar

当我打开某些文件类型时,我想要启动标签栏VIM插件,所以我将以下内容添加到我的.vimrc中:

if has("gui_running")
    autocmd BufEnter *.hs nested TagbarOpen
Run Code Online (Sandbox Code Playgroud)

但是,这并不像我预期的那样有效.它打开一个侧窗,但侧窗不显示任何内容,我的光标被困在其中.我无法通过单击或使用CTRL-W移动命令切换窗口.

但是,当我手动运行TagbarOpen时,它工作得很好.

其他人试过这个,或上面是错误的命令发出?

vim tagbar

7
推荐指数
1
解决办法
3336
查看次数

我可以将范围信息添加到在 exuberant ctags 中使用“--regex-<LANG>”生成的标签吗?

从技术上讲,我在 vim 中使用Tagbar来查看文件的标签,但这个问题应该普遍适用于 exuberant ctags,v5.8。

假设我有以下 python 文件,调用它foo.py

class foo:
    def bar(baz):
        print(baz)
Run Code Online (Sandbox Code Playgroud)

让我们运行ctags一下:ctags foo.py。生成的tags文件如下所示:

!_ some ctags version / formatting stuff not worth pasting
bar foo.py  /^    def bar(baz):$/;" m   class:foo
foo foo.py  /^class foo:$/;"    c
Run Code Online (Sandbox Code Playgroud)

我感兴趣的是第二行的最后一个字段class:foo。这就是函数的范围bar()。如果我在 vim 中使用 tagbar,它会相应地将函数嵌套在类中。

现在假设我在我的~/.ctags. 事实上,我正在添加对此木偶文件的支持:

class foo {
    include bar
}
Run Code Online (Sandbox Code Playgroud)

假设我使用以下~/.ctags参数。“导入”正则表达式很丑陋(呃……对于正则表达式来说很丑陋),但对于这个例子来说它已经完成了足够的工作:

--langdef=puppet
--langmap=puppet:.pp
--regex-puppet=/^class[ \t]*([:a-zA-Z0-9_\-]+)[ \t]*/\1/c,class,classes/
--regex-puppet=/^\ \ \ \ include[ \t]*([:a-zA-Z0-9_\-]+)/\1/i,include,includes/
Run Code Online (Sandbox Code Playgroud)

这会在我的文件中生成以下标记 …

ctags exuberant-ctags tagbar

5
推荐指数
1
解决办法
1299
查看次数

如何用<leader> \打开或关闭NERDTree和Tagbar?

我想<leader>\在以下条件下打开或关闭NERDTree和Tagbar:

  1. 如果NERDTree和Tagbar都打开,则仅关闭两者
  2. 如果NERDTree和Tagbar关闭或者如果已打开,则打开两者

到目前为止,在VIMRC,我有:

nmap <leader>\ :NERDTreeToggle<CR> :TagbarToggle<CR>
Run Code Online (Sandbox Code Playgroud)

这不正确,因为如果一个打开,另一个关闭.它将打开关闭的那个并关闭打开的那个.

怎么能实现这一目标?

vim vim-plugin nerdtree tagbar

4
推荐指数
1
解决办法
3967
查看次数

使用vims tagbar插件来处理latex文件

我目前正在尝试使用vim的tagbar插件来处理Mac OS X上的latex文件.

这是我的〜/ .ctags文件:

--langdef=latex
--langmap=latex:.tex
--regex-latex=/^\\tableofcontents/TABLE OF CONTENTS/s,toc/
--regex-latex=/^\\frontmatter/FRONTMATTER/s,frontmatter/
--regex-latex=/^\\mainmatter/MAINMATTER/s,mainmatter/
--regex-latex=/^\\backmatter/BACKMATTER/s,backmatter/
--regex-latex=/^\\bibliography\{/BIBLIOGRAPHY/s,bibliography/
--regex-latex=/^\\part[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/PART \2/s,part/
--regex-latex=/^\\part[[:space:]]*\*[[:space:]]*\{([^}]+)\}/PART \1/s,part/
--regex-latex=/^\\chapter[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/CHAP \2/s,chapter/
--regex-latex=/^\\chapter[[:space:]]*\*[[:space:]]*\{([^}]+)\}/CHAP \1/s,chapter/
--regex-latex=/^\\section[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\. \2/s,section/
--regex-latex=/^\\section[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\. \1/s,section/
--regex-latex=/^\\subsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\.\. \2/s,subsection/
--regex-latex=/^\\subsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\.\. \1/s,subsection/
--regex-latex=/^\\subsubsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\.\.\. \2/s,subsubsection/
--regex-latex=/^\\subsubsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\.\.\. \1/s,subsubsection/
--regex-latex=/^\\includegraphics[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\3/g,graphic+listing/
--regex-latex=/^\\lstinputlisting[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\3/g,graphic+listing/
--regex-latex=/\\label[[:space:]]*\{([^}]+)\}/\1/l,label/
--regex-latex=/\\ref[[:space:]]*\{([^}]+)\}/\1/r,ref/
--regex-latex=/\\pageref[[:space:]]*\{([^}]+)\}/\1/p,pageref/
Run Code Online (Sandbox Code Playgroud)

这是我的〜/ .vimrc中的相应部分:

let g:tagbar_type_tex = {
    \ 'ctagstype' : 'latex',
    \ 'kinds'     : [
        \ 's:sections',
        \ 'g:graphics:0:0',
        \ 'l:labels',
        \ 'r:refs:1:0',
        \ 'p:pagerefs:1:0'
    \ ],
    \ 'sort'    : 0,
\ }
Run Code Online (Sandbox Code Playgroud)

我基本上从这个链接得到了所有这些:https://github.com/vim-scripts/Tagbar/blob/master/doc/tagbar.txt

不幸的是,当我启动标签栏时,没有任何反应,当我执行时:UpdateTags我收到以下错误:

easytags.vim 3.7: Exuberant Ctags …
Run Code Online (Sandbox Code Playgroud)

vim latex ctags tagbar osx-mavericks

2
推荐指数
1
解决办法
1212
查看次数

VIM:破解ctags或调整标签栏以获得更好的PHP支持

最近,我放弃TaglistTagbar.Tagbar除了PHP之外,所有语言都能正常工作.它将类,方法和变量列入各自的类别,而不是将方法和变量显示在各自的范围内.

我开始知道ctagsPHP的支持很差.

有没有办法改进ctagsTagbar's支持PHP?我正在寻找某种黑客或调整,或任何其他方式.

vim ctags tagbar

2
推荐指数
1
解决办法
1994
查看次数

vim标签栏可以显示局部变量吗?

图像显示全局变量A类,但局部变量不能在tagbar中显示,为什么? 我想要标签栏显示局部变量str,m,n以及如何设置? 图像显示全局变量A类,但局部变量不能在tagbar中显示,为什么?我想要标签栏显示局部变量str,m,n以及如何设置?

vim ctags tagbar

2
推荐指数
1
解决办法
2422
查看次数