简体   繁体   English

如何在vim中的python软件包下查看所有TODO注释?

[英]How to see all TODO comments under a python package in vim?

I'm using python-mode vim plugin for IDE-like development environment and it automatically highlights the word TODO in comments of my source code. 我正在为类似IDE的开发环境使用python-mode vim插件,它会在源代码的注释中自动突出显示TODO一词。

For example, 例如,

# TODO: refactor something!

or, 要么,

"""
TODO: work on something!
"""

and python-mode highlights those words 'TODO'. python-mode突出显示了那些单词“ TODO”。

I wonder if there's any way to list all of these TODO comments of a python package in a new vertical window like vim's NERDTree plugin so that I can see package-level TODOs and work on them. 我想知道是否有办法在新的垂直窗口(如vim的NERDTree插件)中列出python包的所有这些TODO注释,以便我可以看到包级TODO并对其进行处理。

use vimgrep command: 使用vimgrep命令:

:vimgrep /\<TODO\>/j **/*.py
:cope

you can map it to a hotkey 您可以将其映射到热键

:nmap ,t :vimgrep /\<TODO\>/j **/*.py | :cope

or create new command 或创建新命令

:com FindTODO :vimgrep /\<TODO\>/j **/*.py | :cope

The already mentioned TaskList plugin searches only the current file, and uses a scratch buffer for display. 已经提到的TaskList插件仅搜索当前文件,并使用暂存缓冲区进行显示。 My own GrepTasks plugin basically implements the solution in @hhbcarl's answer, using :vimgrep and the quickfix list. 我自己的GrepTasks插件使用:vimgrep和quickfix列表基本上在@hhbcarl的答案中实现了解决方案。 You can search the current file via :GrepHereTasks , all files in a directory via :VimGrepTasks , and several more scopes. 您可以通过搜索当前文件:GrepHereTasks ,所有文件通过目录:VimGrepTasks ,还有几个范围。

为此有一个插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM