[关闭]
@DingCao-HJJ 2015-08-30T13:53:03.000000Z 字数 1059 阅读 1422

vim编程与配置

编程工具/环境 vim


简介

请参考vim_百度百科

vim的模式

vim主要用到的有四种模式:
可视模式
通常的模式,就是粗光标的状态
命令行模式
在可视模式下摁:然后会在窗口最下面的一行出现一个命令窗口,可以调用一些全局的命令,例如替换、保存、退出、查找。
区块模式
可视模式下摁Ctrl+v即可进入,用以选择区块的文本进行编辑、复制、删除等操作
插入模式
可视模式下摁i快捷键进入,可以直接插入文本。

常用命令

可视模式:

快捷键 操作
i(nsert) 进入插入模式,在当前光标处(前)插入
I(nsert at the line begining) 进入插入模式, 在行首插入
a(fter insert) 进入插入模式,在当前光标处(后)插入
a(fter the line insert) 进入插入模式,在行末插入
位置跳转
h 左移一格
l 右移一格
j 下一行
k 下一行
单词跳转
w 下一个单词
b(egin) 上一个单词/当前单词首
e(nd) 单词末尾
行跳转
0 行首
$ 行末
^ 行首字母
( 上一句
) 下一句
滚屏
Ctrl-b 上一屏
Ctrl-f 下一屏
Ctrl-u(p) 上班屏幕
Ctrl-d(own) 下半屏
指定位置
(number+)G(o) 默认去文件末,加上行号跳转到特定行
gg 文件首

以上就是一些比较常用的命令,以后还会陆续添加。如果需要查找更多的命令,请自行查找vim文档。


简单的配置

  1. .vimrc
  2. " sets to a dark scheme."
  3. colorscheme evening
  4. " shows the line numbers"
  5. set nu
  6. set tabstop=2
  7. set nobackup
  8. set showmatch
  9. " highlights the current line and column."
  10. set cursorline
  11. set cursorcolumn
  12. set ruler " adds underline"
  13. " highlights the code limitting column."
  14. set colorcolumn=80,120
  15. set autoindent
  16. " auto shows the invisible tabs and trials"
  17. set listchars=tab:>-,trail:-
  18. set list
  19. " makes the space trials red and visible"
  20. highlight WhitespaceEOL ctermbg=red guibg=red
  21. match WhitespaceEOL /\s\+$/
  22. " trims spaces trials when saves the buffer"
  23. autocmd BufWrite * execute ":s/\s*$//"
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注