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]$ ...
随机推荐
- UED
User Experience Design(用户体验设计),简称UED.UED是进行产品策划的主力之一,他们用自己的知识.经验.设计能力拿出设计方案. UED不只是互联网专家,还是行业专家.能够用自 ...
- HDU 2243 考研路茫茫——单词情结(AC自动机+矩阵)
考研路茫茫——单词情结 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu 4826(dp + 记忆化搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 思路:dp[x][y][d]表示从方向到达点(x,y)所能得到的最大值,然后就是记忆化了. #i ...
- SQLServer 维护脚本分享(08)临时数据库(tempdb)
dbcc sqlperf(logspace) --各数据库日志大小及使用百分比 dbcc loginfo --查看当前数据库的虚拟日志文件 --临时表'Tempdb'最近使用情况 SELECT t1. ...
- C#插件构架实战 + Visual C#插件构架实战补遗(转)
C#插件构架实战 C# 插件构架实战 Jack H Hansen [ 2004-07-27 ] Keywords C# 插件 反射(System.Reflection) 属性(System.Attri ...
- JavaScript给onclick事件赋值,动态传参数实例辩错
错误的例子: <body> <input id="certid" type="text" value="123456" & ...
- 【hdu3948-不同回文串的个数】后缀数组
题意:求不同回文串的个数 n<=10^5 题解: 先按照manacher的构造方法改造一遍串,然后跑一遍manacher. 如ababa--> $#a#b#a#b#a#@ 然后跑一遍后缀数 ...
- node express新项目默认主文件app.js
var express = require('express'); var path = require('path'); var favicon = require('serve-favicon') ...
- js获取浏览器地址
<script type="text/javascript"> window.onload = function(){ var txt=""; va ...
- SpringBoot使用velocity模板引擎
https://my.oschina.net/universsky/blog/704446