Vim技巧
来源:互联网 发布:5x兴趣社区淘宝商店 编辑:程序博客网 时间:2024/06/14 21:50
修改文件
A HAPPY END WITH YEAR 2013!-> A HAPPY NEW YEAR 2014!
fEc2wNEW#ESC#f3r4ZZ
注:
f表示find,fE表示向前查找第一个E,F则指向左查找,FE找寻左边第一个E。
c指擦除,w指word,cw指擦除当前一个word,c2w指向前擦除2个word,执行完cw进入insert模式。
r指replace,r4指将当前字符替换成4,5r4就是把当前连续5个字符替换成4。
Z+Z 连续按下两次Z,文件将保存并退出vim.
*temp var1 0*temp var2 "hi"*temp var3 -1*temp var4 42*temp var5 "asdf"*temp var6 0Simple things we do all the time should be able to be done with very few keystrokes, but sometimes I find something I need to do makes me go, "There MUST be a better way."This challenge is just a simple movement and entering text at a certain place.
->
*temp var1 0*temp var2 "hi"*temp var3 -1*temp var4 42*temp var5 "asdf"*temp var6 0*temp var7 11Simple things we do all the time should be able to be done with very few keystrokes, but sometimes I find something I need to do makes me go, "There MUST be a better way."New text.This challenge is just a simple movement and entering text at a certain place.
EEr7ecw11#ESC#}}oNEW text#CR##ESC#:wq#CR#
Y:复制一行
}:定位到代码块结束
{:定位到代码块开始
P:paste粘贴一行
E:end移动到下一个单词末尾
B:begin移动到单词首
dG:删除到结束
gJ:多行合并成一行,5gJ表示5行合并成一行。
:s/* /,/g:替换操作,将* 替换成,。
x:删除当前字符。
修改文件
foo = a ab abc
->
foo = "a" "ab" "abc"
solution1:2w#C-V#jjI”#ESC#GA”#ESC#k.k.ZZ
2w:跳过两个单词。
. :Repeats the last change made in normal mode
5. :Repeats 5 times the last change made in normal mode
k or Up Arrow: move the cursor up one line
A or a:在当前文字后面插入。
solution2:Gqaciw”#C-R#”“#ESC#Kq2@aZZ
宏命令(Macros):
:qx 开始记录宏,并将结果存入寄存器x
q 退出记录模式
@x 播放记录在x寄存器中的宏命令
删除:一行, 一个字符, 单词, 每行第一个字符
x 删除当前光标下的字符dw 删除光标之后的单词剩余部分d$ 删除光标之后的该行剩余部分dd 删除当前行c 功能和d相同,区别在于完成删除操作后进入INSERT MODEcc 也是删除当前行,然后进入INSERT MODE删除每行第一个字符 :%s/^.//g
安装插件
自动安装.vimrc中配置的插件
:PluginInstall
.vimrc样例:
" Keep "Plugin commands between vundle#begin/end. " plugin on GitHub repo Plugin 'tpope/vim-fugitive' " plugin from http://vim-scripts.org/vim/scripts.html Plugin 'L9' " Git plugin not hosted on GitHub Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) Plugin 'file:///home/gmarik/path/to/plugin' " The sparkup vim script is in a subdirectory of this repo called vim. " Pass the path to set the runtimepath properly. Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Install L9 and avoid a Naming conflict if you've already installed a " different version somewhere else. Plugin 'ascenator/L9', {'name': 'newL9'} Plugin 'nsf/gocode', {'rtp': 'vim/'} " All of your "Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :"PluginList - lists configured plugins " :"PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :"PluginSearch foo - searches for foo; append `!` to refresh local cache " :"PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-"Plugin stuff after this line"my added configsyntax enableset tabstop=4set softtabstop=4set shiftwidth=4set noexpandtabset nuset autoindentset cindent"colorscheme monokai
格式化json
:%!python -m json.tool
- VIM技巧
- vim 技巧
- VIM 技巧
- vim 技巧
- VIM技巧
- vim技巧
- vim技巧
- VIM技巧
- vim技巧
- vim 技巧
- VIM 技巧
- vim技巧
- VIM 技巧
- vim 技巧
- vim 技巧
- vim技巧
- vim技巧
- Vim技巧
- 程序3——二叉树的前中后层序遍历
- 根据文件相对路径获得文件的绝对路径(windows)
- 被忽略却很有用的html标签
- java 集合类
- 关于使用Python3进行网络爬虫的字符问题
- Vim技巧
- 《计算机操作系统》总结三(内存管理)
- 汽车年检,备忘一下,估计2年以后才有用了
- Android studio 安装 环境搭建
- 解决Xshell显示中文乱码的问题
- 实现RTP协议的H.264视频传输系统
- cgi学习笔记
- ambari安装以及基于ambari的hadoop集群搭建
- iOS中触摸事件详解和使用