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 operation的更多相关文章

  1. vim编辑指令(转)

    跳跃指令 类似于游览器中的<前进><后退>按钮  CTRL-] -> 跟着link/tag转入 (follow link/tag)  CTRL-o -> 回到上一次 ...

  2. 实习之vim基本学习

    最近实习学到了写vim的基本用法,记录一下 批量注释 ctrl+v进入列模式,按“I”进入插入模式,按// #等在每行开头插入注释,esc 批量去除注释 ctrl + v 进入列模式,按“x”即可. ...

  3. vim 常用快捷键 二[转]

    键盘移动 (Move) 一切都从键盘的移动k -> 上 upj -> 下 downh -> 左 leftl -> 右 rightz -> 重画屏幕,当前光标变成屏幕的第一 ...

  4. -bash: ulimit: max user processes: cannot modify limit: Operation not permitted

    安装oracle时候在创建oracle用户后,切换oracle用户时,报如下错 [root@localhost ~]# su - oracle-bash: ulimit: max user proce ...

  5. vim模式下报错E37: No write since last change (add ! to override)

    故障现象: 使用vim修改文件报错,系统提示如下: E37: No write since last change (add ! to override) 故障原因: 文件为只读文件,无法修改. 解决 ...

  6. 转:vim模式下报错E37: No write since last change (add ! to override)

    故障现象: 使用vim修改文件报错,系统提示如下: E37: No write since last change (add ! to override) 故障原因: 文件为只读文件,无法修改. 解决 ...

  7. vim 常用 NERDTree 快捷键

    ctrl + w + h 光标 focus 左侧树形目录 ctrl + w + l 光标 focus 右侧文件显示窗口 ctrl + w + w 光标自动在左右侧窗口切换 ctrl + w + r 移 ...

  8. 清理messages提示-bash: /var/log/messages: Operation not permitted的处理

    报警提示系统盘容量不足了/var/log下查看messages日志已经很大了,所以就想着把messages清空一下,以此来释放空间.在删除的时候提示没有权限. 看了下日志,发现是大量的haproxy日 ...

  9. Hadoop 系列文章(一) Hadoop 的安装,以及 Standalone Operation 的启动模式测试

    以前都是玩 java,没搞过 hadoop,所以以此系列文章来记录下学习过程 安装的文件版本.操作系统说明 centos-6.5-x86_64 [bamboo@hadoop-senior opt]$ ...

随机推荐

  1. 信号量进程同步,王明学learn

    信号量进程同步 一组并发进程进行互相合作.互相等待,使得各进程按一定的顺序执行的过程称为进程间的同步. 信号量在进程同步时初始值为:0 信号量在进程互斥时初始值为:大于0的 本章节主要使用信号量,使的 ...

  2. bat学习

    http://www.cnblogs.com/gaohongchen01/p/4042047.html http://www.cnblogs.com/amylis_chen/p/3585339.htm ...

  3. 优秀的API接口设计原则及方法(转)

    一旦API发生变化,就可能对相关的调用者带来巨大的代价,用户需要排查所有调用的代码,需要调整所有与之相关的部分,这些工作对他们来说都是额外的.如果辛辛苦苦完成这些以后,还发现了相关的bug,那对用户的 ...

  4. barabasilab-networkScience学习笔记3-随机网络模型

    第一次接触复杂性科学是在一本叫think complexity的书上,Allen博士很好的讲述了数据结构与复杂性科学,barabasi是一个知名的复杂性网络科学家,barabasilab则是他所主导的 ...

  5. 标签q

    标记短的引用,默认是中文符号:双引号 <p>文字<q>段落中的引用</q>文字</p> 如果是在html里直接敲出引号,是这样的: <p>文 ...

  6. codeforces 286 div2 B

    思路:质因子累乘的值即为所求#include<iostream> #include<algorithm> #include<stdio.h> #include< ...

  7. 网页细分图结果分析(Web Page Diagnostics)

    Discuz开源论坛网页细分图结果分析(Web Page Diagnostics) 续LR实战之Discuz开源论坛项目,之前一直是创建虚拟用户脚本(Virtual User Generator)和场 ...

  8. winform里怎样在一个按钮上实现“单击”和“双击”事件?

    Button按钮是没有双击事件(DoubleClick)的. button1.DoubleClick+=new EventHandler(button1_DoubleClick);使用这种方法在双击的 ...

  9. POJ 2549 二分+HASH

    题目链接:http://poj.org/problem?id=2002 题意:给定一个n个数字组成的序列,然后求出4个数使得a+b+c=d,求d的最大值.其中a,b,c,d要求是给定序列的数,并且不能 ...

  10. 图论 SRM 674 Div1 VampireTree 250

    Problem Statement      You are a genealogist specializing in family trees of vampires. Vampire famil ...