vim - 突出显示 python 文档字符串作为注释(vim 语法突出显示)

标签 vim python-2.7 vim-syntax-highlighting

是否可以修改python.vim (以及相应的 colorcheme 文件),以便在 vim 下的 python 语法突出显示期间,类和 def 语句(也称为文档字符串)下的三引号字符串将突出显示为注释?

class URLopener:
  """Class to open URLs.
  This is a class rather than just a subroutine because we may need
  more than one set of global protocol-specific options.
  Note -- this is a base class for those who don't want the
  automatic handling of errors type 302 (relocated) and 401
  (authorization needed)."""

def addheader(self, *args):
  """Add a header to be used by the HTTP interface only
  e.g. u.addheader('Accept', 'sound/basic')"""

# sample comment

最佳答案

您可以添加以下行:

syn region Comment start=/"""/ end=/"""/

到你的~/.vim/after/syntax/python.vim。如果该文件不存在,您可以创建它。

关于vim - 突出显示 python 文档字符串作为注释(vim 语法突出显示),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16041638/

相关文章:

vim - Vim 中的语法高亮冲突(使用关键字时)

VIM 在使用 split 命令时会丢失语法高亮

linux - 为什么 x>> 在 vi​​m 中有另一个缩进而不是在我按下 Tab 键时?

python-2.7 - 过滤数据以仅获取月份行的第一天

python - 如何在 Python 中使用模拟文件对象进行单元测试?

python - 相对于索引标签的基于整数的偏移量

vim - vim 中当前缓冲区的自定义语法高亮显示

parsing - 文本编辑器中的语法分析

eclipse - Eclipse Project Explorer可以突出显示Vim中存在编译错误的文件?

linux - 同屏执行外部命令