note: 转自 www.quora.com ,很好的网站。
具体链接如下:
https://www.quora.com/What-are-some-impressive-demos-of-Vim-possibilities-for-beginners
其实看英文更容易记住一些,所以贴在这里以后常看看,也希望更多的人看看。
========== Navigation ==========
CTRL+C OR Ctrl+[ instead of ESC.
1/2 ½ BOL (Begin-of-line)
0 BOL (Begin-of-line)
$ EOL (End-of-line)
H Goto HEADER (Top of the screen)
M Goto MIDDLE of BUFFER
L Goto last (bottom).
CTRL+F Page down
CTRL+B Page up
(Handy Page Up / Page Down for Mac where Fn+Up/Down is scrolling Term)
^ Cursor to first non whitespace character
g_ Cursor to last whitespace character
gg (BOF) Beginning of File
G (EOF) End of the file.
10G Goto line 10
:10 Goto line 10
fc Move forward to c (c= character)
Fc Move back to c
gd Goto Definition of Variable
[m Go to function opening
Ctrl+D Page-by-page scrolling
CTRL+O Last location (cursor)
CTRL-I Next location (cursor)
CTRL+^ Alternate file (last edited file in current window)
* Next word
# Previous word
% on brackets {} () [] will find the matching one.
3dd - delete 3 lines
d2f. - delete to the second period.
d% - delete till next pair [, {, (, etc.
v$% - Select whole function (incl. function name)
vi{ - Select function contents
:n /folder/** Open all files (and directories) in folder as buffers (Delete directories and save session for projects)
# [], [[, ]] og ][ what?
zz Cursor to center of screen
z. Cursor to center of screen
z- Cursor to bottom of screen
zb Cursor to bottom of screen
z Cursor to top of screen
zt Cursor to top of screen
========== Change ==========
I INSERT (at beginning)
A INSERT (at end of line)
go INSERT (at end of file)
ci} Change inside brackets
vi} Select inside brackets
dit Delete the text between matching XML tags. (it is for "inner tag block".)
cit Change the text between matching XML tags. (it is for "inner tag block".)
s Substitute char
S Substitute line
c2w Change the next 2 words
dgg Delete to top
dG Delete to bottom
d^ Delete to start of line
D Delete to end of line (or d$)
dt; Delete until ;
d/foo Delete until foo
d} Delete next p-graph
d{ Delete previous p-graph
SHIFT-J Join below line to above ("LINE1\nLINE2" becomes "LINE1 LINE2")
cc Replace Line
S Replace Line
s Replace Letter (Delete then Insert Mode)
cw Replace word
c$ Replace to EOL
c/word Change word and put in INSERT mode.
c?word Change word (search backwards) and put in INSERT mode.
deep Swap two words in front of cursor (Cursor on empty space)
ddp Swap two lines
g- Undo Change
u Undo Change
g+ Redo Change
CTRL+R Redo Change
:earlier Undo by time
:later Redo by time
:undo n Undo by number of actions
:undolist Leaves of undo tree with numbers
y Copy marked text
Y Copy/Yank whole line
y$ Copy/Yank whole line
2yy Copy 2 lines
yw Copy word
ALT+j Move current line UP
ALT+k Move current line DOWN
CTRL-6 Switch between open buffers
ggVG Select All
ggvG= Auto-indenting
== Indent current line
x Delete current character
CTRL+A Increment Number
1CTRL+A Increment Multi-Digit Number
CTRL+X Decrements Number
1CTRL+X Decrements Multi-Digit Number
CTRL+O (Insert-Mode) run normal mode commands and Ex-commands (:echo) temporarily in insert-mode.
:diffthis In two buffers/windows enables diffmode.
ggVGJ join all lines
========== Windows ==========
CTRL+H Window Left ̂
CTRL+L Window Right ̂
CTRL+J Window Down ̂
CTRL+K Window Up ^
CTRL+WW Switch between Windows
CTRL+WR Rotate
CTRL+WQ Quit window
CTRL+WV Split Windows Vertical
CTRL-W_ Minimize window
CTRL-W| Maximize window
CTRL-W+ Grow window
CTRL-W- Shrink window
CTRL+W_ Max height
CTRL + W| Max width
CTRL+W= Set all windows to equal size.
CTRL+W+R Rotate windows (swap left/right top/bottom)
CTRL+W+T Put window in a tab.
CTRL+W+O Close every window but current one.
========== Macro ==========
q Record Macro
qa Run macro (a)
3@q Run macro 3 times
========== Navigation/Files ==========
:cwd Show current working directory
:lcwd Show current (Tab/Window) directory
:ls Show current buffers
:cd Change directory
:lcd Change current (Tab/Window) directory
:new will create a split window with an unnamed buffer.
:enew will open one in the current window.
:vnew will open one in a vertically split window.
:tabnew will open one in a new tab.
vim scp://root@adrafinil//etc/udev/rules.d/10-network.rules
========== Visual commands ==========
> Indent Right
< Indent Left
d Delete marked text
~ Switch case
V Select whole line
========== Insert commands ==========
CTRL-R * will insert in the contents of the clipboard
CTRL-R " (the unnamed register) inserts the the last delete or yank.
========== Search / Replace ==========
/ Search
<SPACE> Search
? Backwards Search
n Next Search ¯
N Previous Search
c/word Change word and put in INSERT mode.
c?word Change word (search backwards) and put in INSERT mode.
:bufdo /searchstr/ Search in all open files
:%s/old/new/g replace all old with new throughout file
:%s/foo/bar/gi The same as above, but ignore the case of the pattern you want to substitute. This replaces foo, FOO, Foo, and so on.
:%s/old/new/gc replace all old with new throughout file with confirmations
:%s/foo/bar/c For each line on the file, replace the first occurrence of foo with bar and confirm every substitution.
:/.*word1\&.*word2 Search for both words simultaneously
:g/^%/s/foo/bar/g Replace every line starting with % with foo with bar
# replace space with newline - literally CTRL-V
:%s/ /<CTRL-V>/g
:sort u - remove duplicate lines
# highlight duplicate lines
:syn clear Repeat | g/^\(.*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"' | nohlsearch
:rs/foo/bar/a Substitute foo with bar. r determines the range and a determines the arguments.
:g/^#/d Delete all lines that begins with #
:g/^$/d Delete all lines that are empty
:g/^///d Delete all // comments
:g/^s*$/d Delete all whitespace lines
:ab mail mail@provider.org Define mail as abbreviation of mail@provider.org (replace when "mail" is written)
:%s/<Ctrl-V><Ctrl-M>//g Remove ^M from files.
========== Marks ==========
m+[A-Z] marks the current line with an alias of the key pressed.
'[A-Z] goes to this mark.
Using marks
========== Misc ==========
. Repeat Command
0p Paste BOL
$p Paste EOL
*p Paste (without indentation) similar to :set paste
# Insert mode
CTRL+R " Paste unnamed/yank register (Insert Mode)
CTRL+R * will insert in the contents of the clipboard (:h i_ctrl-r)
CTRL+R #
CTRL+R : Will insert last cmdline (ex command) (useful for adding a recently typed command to vimrc)
# Normal mode
#p
ZZ Save and quit
g CTRL-G Show Col 1 of 0; Line 5 of 6; Word 1 of 11; Byte 968 of 1019
:help g_CTRL-G
:f Show bufname, modify-status,
"[No Name]" [Modified] line 6 of 6 --100%-- col 49
:help :f
:command show all functions/commands in vim (plugins, custom functions, etc.)
SHIFT+K "Man page" of command under cursor
:%!python -m json.tool - Format JSON pretty in current buffer via Python.
:bn Next Buffer
:bp Previous Buffer
:b # Goto # Buffer. (eg. ':b 1' goto buffer 1)
:b filename
:tab sball Opens a new tab for each open buffer #not recommended, learn to use it, the "right" (tm) way. eg. buffers == tabs, tabs = different viewport arrangement/splits/layout
gt Next Tab
gT Previous Tab
,pp Toggle Paste Mode
,cd Switch CWD to Dir of Open Buffer
:r Read from file into buffer
:r!shellcmd Read shell command into buffer
gf open file under cursor (or import statement)
<c-w>f open in a new window (Ctrl-w f)
<c-w>gf open in a new tab (Ctrl-w gf)
# Set tabline to current directory
:set tabline=[_%{getcwd()}_]
# Relative Directory
:set tabline=%{expand('%:p:h')}
Absolute Path
:set tabline=%{expand('%:p')}
File name
:set tabline=%{expand('%:t')}
#CTAGS
# Generate tags (for goto definition, goto file, taglist) for PHP and template files (*.tpl)
ctags -R --languages=php --langmap=PHP:+.tpl .
ctags -R --languages=php --langmap=PHP:+.tpl --tag-relative=yes --PHP-kinds=+cf .
# Avoid loading vimrc/plugins
gvim -N -u NONE -i NONE (to check for .vimrc/_vimrc causing it)
# Who set filetype?
:verbose set filetype
# Step-by-step autocmd go-through ..
:debug wincmd p
# Output Vim command to file (:buffers in this case)
:redir > outputFile
:buffers
:redir END
# Show character hex, octal, code under cursor
ga
# Quickfix Window (Compiler Messages etc.)
:cw
# Clear last search highlightning
set nohlsearch
# Reverse line order (explanation: Reverse all lines)
:g/^/m0
# Pipe to vim
echo "lel" | vim -
# Show all "set" vim variables
:options
========== Folding ==========
za Toggle folding
zA Toggle folding recursively
zc Close one or count folds under the cursor
zC Close all folds under cursor
zD Delete folds recursively
zE Delete ALL Folds
zf motion - Create a fold
zF Create a fold for count lines
zi Toggle foldenable
zM Close all folds, set foldlevel=0, set foldenable
zR Open all folds and set foldlevel to highest fold level.
zn Fold "none": reset foldenable and open all folds
zN Fold "normal": set foldenable and restore all folds
zo Open one or count folds
z0 Open all folds under the cursor
========== netrw / Explorer ==============
(Built-in filebrowser)
<leftmouse> open
<rightmouse> delete
d New directory
D Delete file(s)/directory(ies)
p Preview file
qb list bookmarks (and recent dirs) ?
mb make bookmark
mB delete bookmark
mf OR <s-leftmouse> Mark files
gb goto bookmark
md diff marked files
mp print marked files
mu unmark all
t enter file in new tab
1u go back 1 history (corresponds to qb-listing)
u forward one directory in history
U backwards one directory in history
========== Plugins / Extensions ==========
Benchmark/Profiling Scripts
vim --startuptime vim.log
--- vim-surround ---
# cs = change surround
# ds = delete surround
# tpope/vim-surround
cs({ - change () to {} - (cursor inside)
ds" - remove " - y
#cst" - surround with "
cs'<b> - add <b> tag (on 'Text' only)
ysiw] - add [] to word (works for <b> tags too)
yss) - add ) to line (works for <b> tags too)
#Visual mode
S" - surround selection with "
gS" - surround with " with newlines before and after content
(V) select text, S<div class="wrap"> -- wrap in this tag
================== Regex ======================
BTsync secrets vim regex
- magic vim "perl regex" operator
- A-Z 0-9
- times 33
- \< \> # means word boundary in-between (this is a word/string)
/\<[A-Z0-9]\{33}\>
======= Win x32/x64 Optimizations NOTES =======
Download custom build from:
#Vim 7.4.796 builds for Windows (32-bit, latest)
Haroogan/veegee are best for YCM compatibility and more..
Page on bitbucket.org (64-bit)
#Cream (for Vim) - Browse /Vim at SourceForge.net
#Wu Yongwei's Programming Page
- vim编辑指令(转)
跳跃指令 类似于游览器中的<前进><后退>按钮 CTRL-] -> 跟着link/tag转入 (follow link/tag) CTRL-o -> 回到上一次 ...
- 实习之vim基本学习
最近实习学到了写vim的基本用法,记录一下 批量注释 ctrl+v进入列模式,按“I”进入插入模式,按// #等在每行开头插入注释,esc 批量去除注释 ctrl + v 进入列模式,按“x”即可. ...
- vim 常用快捷键 二[转]
键盘移动 (Move) 一切都从键盘的移动k -> 上 upj -> 下 downh -> 左 leftl -> 右 rightz -> 重画屏幕,当前光标变成屏幕的第一 ...
- -bash: ulimit: max user processes: cannot modify limit: Operation not permitted
安装oracle时候在创建oracle用户后,切换oracle用户时,报如下错 [root@localhost ~]# su - oracle-bash: ulimit: max user proce ...
- vim模式下报错E37: No write since last change (add ! to override)
故障现象: 使用vim修改文件报错,系统提示如下: E37: No write since last change (add ! to override) 故障原因: 文件为只读文件,无法修改. 解决 ...
- 转:vim模式下报错E37: No write since last change (add ! to override)
故障现象: 使用vim修改文件报错,系统提示如下: E37: No write since last change (add ! to override) 故障原因: 文件为只读文件,无法修改. 解决 ...
- vim 常用 NERDTree 快捷键
ctrl + w + h 光标 focus 左侧树形目录 ctrl + w + l 光标 focus 右侧文件显示窗口 ctrl + w + w 光标自动在左右侧窗口切换 ctrl + w + r 移 ...
- 清理messages提示-bash: /var/log/messages: Operation not permitted的处理
报警提示系统盘容量不足了/var/log下查看messages日志已经很大了,所以就想着把messages清空一下,以此来释放空间.在删除的时候提示没有权限. 看了下日志,发现是大量的haproxy日 ...
- Hadoop 系列文章(一) Hadoop 的安装,以及 Standalone Operation 的启动模式测试
以前都是玩 java,没搞过 hadoop,所以以此系列文章来记录下学习过程 安装的文件版本.操作系统说明 centos-6.5-x86_64 [bamboo@hadoop-senior opt]$ ...
随机推荐
- hibernate 关联映射
关联关系大致分为两大类: 1.单向关系:只需单向访问关联端.例如:只能通过老师访问学生,或者只能通过学生访问老师. 2.双向关系:关联的两端可以互相访问.例如:老师和学生之间可以互相访问. 单向关联可 ...
- WINDOWS系统Eclipse+NDK+Android + OpenCv
WINDOWS系统Eclipse+NDK+Android + OpenCv 参考文档博客 1 NDK环境搭建 http://jingyan.baidu.com/article/5d6edee22d90 ...
- HDU 2896 病毒侵袭(AC自动机)
病毒侵袭 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- JQuery经典小例子——可编辑的表格
可编辑的表格: 屏幕剪辑的捕获时间: 2015/8/14 9:16 HTML代码为: <!DOCTYPE html> <htmlxmlns="http://www.w3.o ...
- 用户视角 vs 系统视角 看性能
如何评价性能的优劣: 用户视角 vs. 系统视角 对于最终用户(End-User)来说,评价系统的性能好坏只有一个字——“快”.最终用户并不需要关心系统当前的状态——即使系统这时正在处理着成千上万的请 ...
- LoadRunner Pacing设置(转)
转载的,备读 在 LoadRunner 的运行场景中,有一个不大起眼的设置,可能经常会被很多人忽略,它就是Pacing .具体设置方式为: Run-Time settings à General à ...
- java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory 解决方案
缺少 commons-logging.jar
- apk签名(不打包)
apk提交给应用市场加固后,需要重新签名 签名工具:360签名 下载地址:http://yunpan.cn/cm8GqVWL7Y8Eh 签名步骤:http://jiagu.360.cn/qcms/he ...
- LoadRunner常用函数列表
LoadRunner常用函数列表 Web相关函数 函 数 功 能 描 述 web_custom_request 用户可以通过该函数自行创建一个HTTP请求的函数 web_image 模拟用户单击 ...
- 从客户端(CourseIssueContent="<P>财务审计师岗位认证招生简章<BR>...")中检测到有潜在危险的 Request.Form 值。
说明: 请求验证过程检测到有潜在危险的客户端输入值,对请求的处理已经中止.该值可能指示危及应用程序安全的尝试,如跨站点的脚本攻击.通过在 Page 指令或 配置节中设置 validateRequest ...