Autoclose xml tags in C/C++ file in vim

亡梦爱人 提交于 2020-01-06 03:55:07

问题


I have some documentation strings embedded within the source code (C/C++ files) as XML tags and I'd like to know what's the most minimal solution to make vim autoclose the tags (closest matching tag).

I've found closetag.vim but is there away to do this neatly without modifying anything but the .vimrc file?


回答1:


Vim has no built-in support for that, so the closetag.vim plugin is the proper and easiest solution. (I use it myself, too!) Of course, you can develop your own simple mappings (that search backwards for an open tag, get that, drop the attributes, add the slash, and insert that), but:

  • that will either be very simplistic and therefore often wrong
  • or ends up with as much complexity as closetag, becoming a reimplementation of that plugin

If some rather strange restrictions (e.g. a custom primitive sync across systems) only allow you to manipulate the ~/.vimrc itself, you could just append the entire plugin's code to it (though I'd recommend against such an ugly hack).



来源:https://stackoverflow.com/questions/20925113/autoclose-xml-tags-in-c-c-file-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!