VIM命令集
| Command | Action | Notes |
| vim file +54 | open file and go to line 54 | any : command can be run using + on command line |
| vim -O file1 file2 | open file1 and file2 side by side | |
| Insert | enter insert mode | so you can start typing. Alternatively one can use i ora. |
| Esc | leave insert mode | so you can issue commands. Note in VIM the cursor keys & {Home, End, Page{up,down}} and Delete and Backspace work as expected in any mode, so you don't need to go back to command mode nearly as much as the origonal vi. Note even Ctrl+{left,right} jumps words like most other editors. Note also Ctrl+[ and Ctrl+c are equivalent to Esc and may be easier to type. Also Ctrl+o in insert mode will switch to normal mode for one command only and automatically switch back. |
| :command | runs named command | |
| :help word | shows help on word | Typing Ctrl+d after word shows all entries containing word |
| :echo &word | shows value of word | |
| windows | ||
| :e | set buffer for current window | you can optionally specify a new file or existing buffer number (#3 for e.g.). Note if you specify a directory a file browser is started. E.g. :e . will start the browser in the current directory (which can be changed with the :cd command). |
| :sp | new window above | ditto |
| :vs | new window to left | ditto |
| :q | close current window | |
| :qa | close all windows | add trailing ! to force |
| Ctrl+w {left,right,up,down} | move to window | |
| Ctrl+w Ctrl+w | toggle window focus | |
| Ctrl+w = | autosize windows | to new terminal size for e.g. |
| :ba | new window for all buffers | ":vert ba" tiles windows vertically |
| buffers | ||
| :ls | list buffers | |
| gf | open file under cursor | |
| :bd | delete buffer | and any associated windows |
| :w | save file | Note :up[date] only writes file if changes made, but it's more awkward to type |
| :sav filename | save file as filename | Note :w filename doesn't switch to new file. Subsequent edits/saves happen to existing file |
| undo/redo | ||
| u | undo | |
| Ctrl+r | redo | |
| . | repeat | |
| navigation | ||
| gg | Goto start of file | |
| G | Goto end of file | |
| :54 | Goto line 54 | |
| 80| | Goto column 80 | |
| Ctrl+g | Show file info | including your position in the file |
| ga | Show character info | g8 shows UTF8 encoding |
| Ctrl+e | scroll up | Ctrl+x needed first for insert mode |
| Ctrl+y | scroll down | Ctrl+x needed first for insert mode |
| zt | scroll current line to top of window | |
| w | Goto next word | Note Ctrl+{right} in newer vims (which work also in insert mode) |
| b | Goto previous word | Note Ctrl+{left} in newer vims |
| [{ | Goto previous { of current scope | |
| % | Goto matching #if #else,{},(),[],/* */ | must be one on line |
| zi | toggle folds on/off | |
| bookmarks | ||
| m {a-z} | mark position as {a-z} | E.g. m a |
| ' {a-z} | move to position {a-z} | E.g. ' a |
| ' ' | move to previous position | |
| '0 | open previous file | handy after starting vim |
| selection/whitespace | ||
| v | select visually | use cursor keys, home, end etc. |
| Shift+v | line select | CTRL+v = column select |
| Delete | cut selection | |
| "_x | delete selection | without updating the clipboard or yank buffer. I remap x to this in my .vimrc |
| y | copy selection | |
| p | paste (after cursor) | P is paste before cursor |
| "Ay | append selected lines to register a | use lowercase a to initialise register |
| "ap | paste contents of a | |
| gq | reformat selection | justifies text and is useful with :set textwidth=70 (80 is default) |
| = | reindent selection | very useful to fix indentation for c code |
| > | indent section | useful with Shift+v% |
| < | unindent section | remember . to repeat and u to undo |
| :set list! | toggle visible whitespace | See also listchars in my .vimrc |
| clipboard shortcuts | ||
| dd | cut current line | |
| yy | copy current line | |
| D | cut to end of line | |
| y$ | copy to end of line | |
| search/replace | ||
| /regexp | searches forwards for regexp | ? reverses direction |
| n | repeat previous search | N reverses direction |
| * | searches forward for word under cursor | # reverses direction |
| :%s/1/2/gc | search for regexp 1 and replace with 2 in file | c = confirm change |
| :s/1/2/g | search for regexp 1 and replace with 2 in (visual) selection | |
| programming | ||
| K | lookup word under cursor in man pages | 2K means lookup in section 2 |
| :make | run make in current directory | |
| Ctrl+] | jump to tag | Ctrl+t to jump back levels. I map these to Alt+⇦⇨ in my .vimrc |
| vim -t name | Start editing where name is defined | |
| Ctrl+{n,p} | scroll forward,back through autocompletions for word before cursor | uses words in current file (and included files) by default. You can change to a dictionary for e.g: set complete=k/usr/share/dicts/words Note only works in insert mode |
| Ctrl+x Ctrl+o | scroll through language specific completions for text before cursor | "Intellisense" for vim (7 & later). :help compl-omni for more info. Useful for python, css, javascript, ctags, ... Note only works in insert mode |
| external filters | ||
| :%!filter | put whole file through filter | |
| :!filter | put (visual) selection through filter | |
| :,!command | replace current line with command output | |
| map <f9> :w<CR>:!python %<CR> | run current file with external program | |
(来源:http://www.pixelbeat.org/vim.tips.html)
VIM命令集的更多相关文章
- linux---Vim命令集
Vim命令集 命令历史 以:和/开头的命令都有历史纪录,能够首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗体中输入下面命令就可以 vim 直接启动vim vim filena ...
- [转载]VIM命令合集
Vim命令合集 http://www.cnblogs.com/softwaretesting/archive/2011/07/12/2104435.html 命令历史 以:和/开头的命令都有历史纪录, ...
- Vim命令合集(四)
Vim命令合集 命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 vim 直接启动vim vim filena ...
- 【转】Vim命令合集
Vim命令合集 命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 vim 直接启动vim vim filena ...
- Vim命令大全
1.进入vi的命令 vi filename :打开或新建文件,并将光标置于第一行首 vi +n filename :打开文件,并将光标置于第n行首 vi + filename :打开文件,并将光标置于 ...
- Mysql 常用命令集
1.mysqlbinlog工具使用方法如下: 先使用 show binary logs 查看 在使用导出命令 mysqlbinlog -R -uroot -pxxxx -hxxx.xxx.xxx.xx ...
- 【转】vim 命令
Vim命令合集 建议直接看原文:(排版有些乱) 命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 vim 直接 ...
- centos LB负载均衡集群 三种模式区别 LVS/NAT 配置 LVS/DR 配置 LVS/DR + keepalived配置 nginx ip_hash 实现长连接 LVS是四层LB 注意down掉网卡的方法 nginx效率没有LVS高 ipvsadm命令集 测试LVS方法 第三十三节课
centos LB负载均衡集群 三种模式区别 LVS/NAT 配置 LVS/DR 配置 LVS/DR + keepalived配置 nginx ip_hash 实现长连接 LVS是四层LB ...
- linux下vim命令
进入vim的命令 vim filename :打开或新建文件,并将光标置于第一行首 vim +n filename :打开文件,并将光标置于第n行首 vim + filename :打开文件,并将光标 ...
随机推荐
- oracle切割字符串后以单列多行展示
原始的sql: select substr(field1, instr(field1, '|', 1, rownum) + 1, instr(field1, '|', 1, rownum + 1) - ...
- vs2005及以上版本的程序分发问题
我们使用vs2005及以上版本编译的应用程序(C/C++),在客户机器运行时,会出现: “由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题” 那么,我们怎么解决这个问题呢 ...
- qt宽字符串中文乱码(codec->toUnicode值得学习)
乱码原因: QT使用的是utf-8 简体中文版的windows操作系统及其应用软件默认都是ANSI/GBK编码.而且这里应该是宽字符串. 多字节ANISGB 宽字符UNICODE 多字节显示标准字符的 ...
- 与众不同 windows phone (8) - Tile(磁贴)
原文:与众不同 windows phone (8) - Tile(磁贴) [索引页][源码下载] 与众不同 windows phone (8) - Tile(磁贴) 作者:webabcd介绍与众不同 ...
- Android平均分布的布局图像的下一行
Android下一行平均分布图片的布局 这是一个非经常见的需求,比方有三个图片button,须要在底部三个平均,比方下个样例: 下面是布局文件 <LinearLayout android:lay ...
- VC 中与字符串相关的宏 _T、TEXT,_TEXT、L 的作用(简单明了)
一. 在字符串前加一个L作用: 如 L"我的字符串" 表示将ANSI字符串转换成unicode的字符串,就是每个字符占用两个字节. strlen("as ...
- Delphi默认窗体随想
Delphi中新建一个Form或者Frame时,它的字体都是西文习惯,这样就有可能造成在其他机器上由于字体的原因,窗体十分不美观.怎样才能为Delphi设置一个默认窗体,让它的字体Font符合中国习惯 ...
- 在VC++中启用内存泄露检测
检测内存泄漏的主要工具是调试器和 CRT 调试堆函数.若要启用调试堆函数,请在程序中包括以下语句: #define CRTDBG_MAP_ALLOC#include <stdlib.h># ...
- Android---OpenGL ES之添加动作
本文译自:http://developer.android.com/training/graphics/opengl/motion.html 在屏幕上绘制对象是OpenGL的最基本功能,你可以使用其他 ...
- ActiveX 暴漏你全部信息的可怕的插件!
近期在项目中常常接触ActiveX控件,对于这个名词相信仅仅要是上网看视频的用户一定都会遇到adobe更新或者载入的提示,这就是一个ActiveX控件.一直以为Active控件是处理复杂的页面逻辑提供 ...