v:按字符选择。 对高亮选区的操作:
HotKey collections
notepad++
ctrl+alt+shift+x : open in firefox
ctrl+alt+shift+i : open in IE
Ctrl-D : 复制当前行
Ctrl-L : 删除当前行
Ctrl-Space : 下拉提示信息
Ctrl-Shift-Space : complete word
F11 : 全屏显示
Ctrl-Tab : 下一个文档
Ctrl-Shift-Tab : 上一个文档
Ctrl-U : 转换为小写
Ctrl-Shift-U : 转换为大写
Ctrl-Shift-R : 开始/结束录制宏
Ctrl-Shift-P : 执行宏
bash ctrl+w : delete a word backward (alt+Backspace )
ctrl+u : delete to the begin of cmdline from current cursor
ctrl+k : delete to the end of cmdline from current cursor
ctrl+h : delete a character backward
ctrl+d : delete a character forward
ctrl+a : move to begin of cmdline
ctrl+e : move to end of cmdline
ctrl+l : clear whole screen
ctrl+r : reverse complement history cmd
ctrl+j : like enter
ctrl+b : move back a character
ctrl+f : move forward a character
alt+u : uppercase next word
alt+l : lowercase next word
firefox ctrl/alt+num : switch to the num-th tab
ctrl+j : show/hide download dialog window
ctrl+l : go to the address link lineeditor
ctrl+k/e : go to the search lineeditor
ctrl+n : open a new firefox window
ctrl+t : new tab
ctrl+w : close current firefox tab/window
ctrl+u : show http source code
ctrl+h : show history
vi (vimtutor is helpful)
(.vimrc配置 http://hi.baidu.com/gzhejj/blog/item/29fca91be4bc6e198718bfb8.html )
ref: http://www.linuxdiyf.com/blog?68518/action_viewspace_itemid_1322.html
?pattern : 向前寻找指定的pattern ,若遇到文件头,则从尾再开始。
nx : 删除由光标位置起始的n个字符
ndw : 删除光标位置其实的n个字符组(dw删除到字的末尾)
db : 从字的开始删除
d0 : 将行的开始到光标位置的字符全部删除
d$ 或D : 将光标位置起始到行尾的字符全部删除
dd : 删除一行
:start,endd : 删除文件的第start到end行
R : 覆盖本行内容
u : 恢复上一次的修改 (undo)
U : 恢复对整行修改之前的状态
ctrl+r : 与u相反 (redo)
o : 在光标所在行后插入一空行
O : 在光标所在行前插入一空行
yy : 把当前行放入缓冲区
yw : 把光标所在的单词放入缓冲区
p : 将缓冲区内容取到光标所在行的下面一行
P : 将缓冲区内容取到光标所在行的上面一行
e! : 重新装入当前文件,若当前文件有改动,则丢弃以前的改动
guw : 将当前单词转化为小写(gUw则为大写)
guu : 将当前行单词转化为小写(gUU则为大写)
f+char : jump to the next character (分号(;)将重复执行最后一个f、F、t或者T命令)
F+char : jump to the previous character
ctrl+d : page down (half page)
ctrl+u: page up (half page)
ctrl+f: page down
ctrl+b: page up
j : move down
k : move up
h : move left
l : move right
H : jump to the beginning of the first line in current page
L : jump to the beginning of the last line in current page
M : jump to the beginning of the middle line in current page
J : delete the ‘n’ of current line (join)
K : go to the manual of current word
z- 把当前行作为屏幕的最后一行,并重新显示屏幕。
z. 把当前行作为屏幕的中间一行,并重新显示屏幕。
ctrl+e : move the whole page up one line
ctrl+y : move the whole page down one line
gg : jump to the beginning of the first line
G : jump to the beginning of the last line
# G: jump to line number #
$ : jump to the end of current line
^/0 : jump to the beginning of current line
ctrl+g : show line info & file name
:f : 同 ctrl+g
ctrl+t : 对行增加一个级别的缩进 (insert mode)
ctrl+d : 对行取消一个级别的缩进 (insert mode)
<< : 将行向左移动8个空格 (cmd mode)
>> : 将行向右移动8个空格 (cmd mode)
n<< 或 n>> : 将连续n行向左或向右缩进8个空格
% : 匹配括号(、[、{、< (cmd mode)
gd:到达光标所在处函数或者变量的定义处。
ctrl+w+v : 垂直方向分割窗口
ctrl+w+s : 水平方向分割窗口
ctrl+w+n : 水平方向产生一个新窗口
ctrl+w+< : 垂直分割线左移
ctrl+w+ - : 水平分割线上移
ctrl+w+w : 切换窗口
ctrl+w+c : 关闭窗口
ctrl+w+o : 仅保留当前窗口,关闭其他所有窗口
:split filename : open a file in a new window
ref:http://vimcdoc.sourceforge.net/doc/index.html#CTRL-W
:#1,#2s/text1/textx2/g : 在两行#1和#2之间,replace text1 to text2
:%s/old/new/g : 在整个文件中,查找所有old并替换为new
:%s/old/new/gc : 在替换之前会询问yes or no
:first,last co dest 将first 到last行的数据复制到目标行(dest)下面
:Start,end m dest 将start 到 end行的数据移动到目标行(dest)下
:r filename 将指定文件的内容读入光标所在行下
:1,5 copy 7 块拷贝
:1,5 del 块删除
:1,5 move 7 块移动
d) : 删除到句子的末尾
d4) : 删除到第4个句子的末尾
d( : 从句子的首字符开始删除
d} : 删除到段落末尾
d{ : 从段落的开始删除
d/text : 一直删除到text单词的下一次出现
dL : 删除到屏幕的最后一行(包括最后一行)
dH : 从屏幕的第1行开始删除
:set showmatch 或 :set sm : 当我们输入)或}时,光标在返回当前位置之前将短暂地移回到相匹配的(或{处
:set autoindent 或 :set ai : 使用自动缩进功能
:set tags=../../tags
tags设置好后,在~/.vimrc里加入 “filetype plugin indent on” 后
ctrl+x, ctrl+o : 代码补齐
ctrl+e : 撤销当前补齐
在插入模式下 ctrl+x, ctrl+?
ctrl+x, ctrl+e : 向上scroll
ctrl+x, ctrl+y : 向下scroll
ctrl+x, ctrl+i : path pattern 补全
ctrl+x, ctrl+v : 补全
ctrl+p : 补全
ctrl+n : 补全
命令.(句点)将重复执行最近一次的修改命令
f+char : jump to the next character (分号(;)将重复执行最后一个f、F、t或者T命令)
: 搜索下一个当前光标处单词
# : 搜索前一个当前光标处单词
可视选择模式
V:按行选择。
Ctrl-V:按块选择。
d:剪贴选择的内容到剪贴板。
y:拷贝选择的内容到剪贴板。
c:剪贴选择的内容到剪贴板并且进入插入模式。
register - 暂存寄存器
:h registers 帮助
"+yy 拷贝到寄存器
"+p 从寄存器粘贴出来
:di 列出各个寄存器内容
"1p 贴出寄存器1的内容,继续按下「.」的時候 vim 就會把 "2 的內容貼出來,依此類推
:let @a="Hello, world" 设置寄存器a的内容
:g/pattern/y a 每次比對到的那行都 yank 複製到 "a 這裡面去,只會记录到最後一行的結果
:g/pattern/y A 与a不同,A会append内容到 "a
:g/pattern/. w >> filename 把這些東西寫到某個檔案去
"+和" 系统全局的剪贴板
": 就是指打的命令的暫存器
"/ 就是放搜尋的字串
". 放最近 insert 插入的文字
"- 放砍掉但不超過一行的文字
"% 指現在編輯的檔名
:w %.bak 将当前文件另存为currentfilename.bak
others
:digraph
显示unicode符号,例如 (" 【 12304,第一部分表示用户输入的字符组合,中间是显示的符号,最后是该字符的unicode编码
输入ctrl+K+(+"即可显示出【
ctags
ctags -R * : generate tags file recursively
cscope
cscope -Rbkq : 建立索引
taglist
:Tlist 显示当前.c文件中的变量、函数等
fold
:help fold
:set foldmarker={,}
:set foldmethod=marker
:set foldmethod=syntax
:set foldlevel=100 " Don’t autofold anything (but I can still fold manually)
:set foldopen-=search " don’t open folds when you search into them
:set foldopen-=undo " don’t open folds when you undo stuff
zc Close one fold under the cursor.
zC Close all folds under the cursor recursively.
zo Open one fold under the cursor.
zO Open all folds under the cursor recursively.
zM Close all folds: set ‘foldlevel’ to 0.
zR Open all folds.
加密
:X 然后输入密码(直接输入回车则撤销密码)
mark
m{a-zA-Z} 将当前光标位置设置为mark
‘a 跳转到mark a的位置
:set sm 在用户敲)、]、}时显示出对应匹配的{、[、(
缩写文本
:ab myurl http://www.mykms.org/kms/myproject/index.php? id=0023
在插入模式下输入“myurl”后,“myurl”就会自动变成刚才定义URL
:una myurl 取消myurl这个缩写
set encoding=utf-8 " set default encoding as UTF-8
set fileencodings=ucs-bom,utf-8,cp936,latin1 " fileconding detection order
set termencoding=utf-8 " support Chinese display in rxvt-unicode
=============================================================================