vim编辑器的一些其他用法

来源:互联网 发布:linux配置自动获取ip 编辑:程序博客网 时间:2024/06/05 07:20

删除列

1.光标定位到要操作的地方。
2.CTRL+v 进入“可视 块”模式,选取这一列操作多少行。
3.d 删除。

插入列

插入操作的话知识稍有区别。例如我们在每一行前都插入”() “:
1.光标定位到要操作的地方。
2.CTRL+v 进入“可视 块”模式,选取这一列操作多少行。
3.SHIFT+i(I) 输入要插入的内容。
4.ESC 按两次,会在每行的选定的区域出现插入的内容。

一些特色功能:

自动文件头注释与模板定义

"###################    set file head start  #########################"autocmd创建新文件自动调用setfilehead()函数autocmd BufNewFile *.v,*.sv,*.cpp,*.c,*.h exec ":call Setfilehead()"func Setfilehead()    call append(0, '/***********************************************')    call append(1, '#')    call append(2, '#      Filename: '.expand("%"))    call append(3, '#')    call append(4, '#        Author: Clough - clough@gmail.com')    call append(5, '#   Description: ---')    call append(6, '#        Create: '.strftime("%Y-%m-%d %H:%M:%S"))    call append(7, '# Last Modified: '.strftime("%Y-%m-%d %H:%M:%S"))    call append(8, '***********************************************/')"    call append(9, '')endfunc"map F2 to creat file head comment"映射F2快捷键,生成后跳转至第10行,然后使用o进入vim的插入模式map <F2> :call Setfilehead()<CR>:10<CR>o"###################    set file head end   ##########################

文件内部注释快捷键生成

"###################    set comment start  #########################func SetComment()    call append(line(".")  , '//**************** comment start ********************')    call append(line(".")+1, '//**************** comment end   ********************')endfunc"映射F11快捷键,生成后跳转至下行,然后使用O进入vim的插入模式map <F11> :call SetComment()<CR>j<CR>O"###################    set comment end   ##########################

跳转括号

%

原创粉丝点击