第十四章 个人渣翻译 spf13插件---NERDCommenter 使用教程
2016-10-25 04:56
465 查看
看看spf13中的介绍:
NERDCommenter allows you to wrangle your code comments, regardless of filetype. Viewhelp :NERDCommenteror checkout my post onNERDCommenter.QuickStart Toggle comments using
<Leader>c<space>in Visual or Normal mode. 渣翻译:NERDCommenter允许你快速注释代码段,不限文件类型。快速启动:<leader>c<space>在可视模式或普通模式 插件功能介绍非常简单,我们来看看NERDCommenter官网: Most of the following mappings are for normal/visual mode only. The|NERDComInsertComment| mapping is for insert mode only.
[count]<leader>cc|NERDComComment|Comment out the current line or text selected in visual mode.
[count]<leader>cn|NERDComNestedComment|Same as cc but forces nesting.
[count]<leader>c<space>|NERDComToggleComment|Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa.
[count]<leader>cm|NERDComMinimalComment|Comments the given lines using only one set of multipart delimiters.
[count]<leader>ci|NERDComInvertComment|Toggles the comment state of the selected line(s) individually.
[count]<leader>cs|NERDComSexyComment|Comments out the selected lines with a pretty block formatted layout.
[count]<leader>cy|NERDComYankComment|Same as cc except that the commented line(s) are yanked first.
<leader>c$|NERDComEOLComment|Comments the current line from the cursor to the end of line.
<leader>cA|NERDComAppendComment|Adds comment delimiters to the end of line and goes into insert mode between them.|NERDComInsertComment|Adds comment delimiters at the current cursor position and inserts between. Disabled by default.
<leader>ca|NERDComAltDelim|Switches to the alternative set of delimiters.
[count]<leader>cl
[count]<leader>cb|NERDComAlignedComment|Same as |NERDComComment| except that the delimiters are aligned down the left side (
<leader>cl) or both sides (
<leader>cb).
[count]<leader>cu|NERDComUncommentLine|
用法渣翻译:
绝大多数默认映射只能用于可视模式和普通模式。[count]<leader>cc 在可视模式下注释当前行或选定的文本 [count]<leader>cn 和cc作用类似,但可以嵌套注释 [count]<leader>c<space>切换选定行的注释状态,如果选定的最上面一行已经被注释了,那么就取消注释,反之亦然 [count]<leader>cm如果可能的话,用多个分隔符来注释给出的行 [count]<leader>ci分开切换选定行的注释状态,每一个选定行如果被注释了,那么取消注释,反之亦然 [count]<leader>cs用一个漂亮的格式化块,注释被选定行 [count]<leader>cy和cc作用相同,区别在于先复制要注释的行 <leader>c$从光标开始,到一行结尾开始注释 <leader>cA把注释分隔符,添加到一行末尾 <leader>ca切换到分隔符的备用设置 [count]<leader>cl[count]<leader>cb [count] <leader>cb和cc作用相同,区别在于分隔符左对齐(cl),右对齐(cr),中间对齐(cb)[count]<leader>cu取消选定行的注释
个人总结:
通常需要注释时,到每行代码前输入 //,取消注释时再删除 //,这种方式太过麻烦。应该支持对选中文本块批量(每行)添加注释符号,反之,可批量取消。本来 vim 通过宏方式可以支持该功能,但每次注释时要自己录制宏,关闭 vim 后宏无法保存。所以有人专门编写了一款插件 NERD Commenter ,它根据编辑文档的扩展名自适应采用何种注释风格。默认的功能映射很多,没有必要全部记忆,通常只需要记两个,添加注释(cc),取消注释(cu)。个人实践:
无论在普通模式还是可视模式,每次使用<leader>cc就会删除文本,并进入插入模式。换句话说,注释插件没有生效。换用<leader>cn, <leader>cm均不起作用,为什么呢?网上查询资料,有一种说法是:①想要命令生效,需要将光标置于每行的空白处,也就是说光标上不能有字符。个人实验发现这种办法是无效的,在空白处按下<leader>cc,同样会删除选定行,并进入插入模式。继续查找资料,另一种说法是:②在vimrc中添加set nocompatible 关闭兼容我们已经安装了spf13集合包,兼容模式必然是关闭的,为了确定手工在vimrc添加,依然无效。最后重启ubuntu 操作系统,再次进入vim,<leader>cc正常工作了。个人分析:安装完spf13集合包后,并没有重启操作系统,可能是某些插件代码未能很好的启动。 类似于Windows系统打了补丁后,没有重启,造成系统异常。注释是传统的/* */写法,假设想要使用//写法,在vim里面用<leader>ca可以将注释格式改成alternative格式。对于C源码来说,这个alternative格式就是//写法。相关文章推荐
- 第十二章 个人渣翻译 spf13插件---ctrlp 使用教程
- 第十三章 个人渣翻译 spf13插件---surround 使用教程
- 第十五章 个人渣翻译 spf13 插件---neocomplete使用教程
- 第十七章 个人渣翻译 spf13插件---Tagbar(ctags) 使用教程
- 第九章 个人渣翻译 spf13插件---nerdtree 使用教程(上)
- 第七章 个人优化vim第四步:插件集合spf13安装与使用教程
- 第十六章 spf13 插件---neosnippet使用教程
- 第八章 个人渣翻译 spf13插件---undotree 使用教程
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之十三:在DetailsView控件中使用TemplateField
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之十二:在GridView控件中使用TemplateField
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之四十八:在SqlDataSource中使用参数化查询
- Spket Eclipse插件使用教程
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之十四:使用FormView 的模板
- AutoCode (vs插件)自动生成代码插件 下载及使用教程(C#版)( 更新简单自定义模板教程)
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之四十七:使用SqlDataSource控件查询数据
- Dreamer的FLEX教程翻译:在Flex中使用资源包
- AutoCode (vs插件)自动生成代码插件 下载及使用教程(C#版)
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之十二:在GridView控件中使用TemplateField
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之十四:使用FormView 的模板
- [翻译] Scott Mitchell 的ASP.NET 2.0数据操作教程之十:使用 GridView 和DetailView实现的主/从报表