VIM 技巧

match & replace

  • match the whole word(eg: match printf but not snprintf/fprintf)
    You can use \< to match the beginning of a word and > to match the end:

    1. %s/\<printf\>/PRINTF/gc
  • match the current line to last line of file

    1. .,$s/printf/PRINTF/gc
  • match the current line to the next two line of file

    1. .,+2s/printf/PRINTF/gc
  • replace word contain /, eg. printf->//print

    1. :s!printf!//printf!gc

text selection

链接地址
If you want to do the same thing to a collection of lines, like cut, copy, sort, or format, you first need to select the text. Get out of insert mode, hit one of the options below, and then move up or down a few lines. You should see the selected text highlighted

Key description
V selects entire lines
v selects range of text
ctrl-v selects colums
gv reselect block

Word & line completion

链接地址

Key description
ctrl-n next word completion(similar word in current file
ctrl-p previous word completion(similar word in current file
ctrl-x, ctrl-l line completion
ctrl-w erases word (insert mode)
ctrl-u erases line ... or on command line

when we command set path value

  1. :set dictionary=/usr/share/dict/words

then, ctrl-x, ctrl-k, the dictionary completion

markers

链接地址
Use markers to set places you want to hotfoot get back to, or to specify a block of text you want to copy or cut.

key description
ma a mark current position as mark a(can use a-z)
'k move to mark k
d'k delete form current positon to mark k
'a-z same file

reformatting

链接地址
These are useful to reformat text paragraphs or chunks of code (NOTE: This does not python code ...)

key description
V= select text, then reformat with =
= will correct alignment of code
== one line
gq reformat paragraph

Folding

链接地址
Use folds to collapse selected blocks. Useful if you have finished a subroutine and want to save window space, or maybe want to fold allboocks of comments

key description
zo open current scope fold
zc close current scope fold
zO open current scope fold and sub scope fold
zC close current scope fold and sub scope fold

insert text beginning multi-line of same columns

链接地址

  • Use Ctrl+V to select the first column of text in the lines you want to comment.
  • Then hit shift+i and type the text you want to insert.
  • Then hit Esc wait 1 second and the inserted text will appear on every line.

vi技巧合集的更多相关文章

  1. javascript技巧合集

    转http://www.blogjava.net/zhaochengming/archive/2010/04/09/317837.html http://www.cnblogs.com/fxgachi ...

  2. SpringBoot | 番外:使用小技巧合集

    前言 最近工作比较忙,事情也比较多.加班回到家都十点多了,洗个澡就想睡觉了.所以为了不断更太多天,偷懒写个小技巧合集吧.之后有时间都会进行文章更新的.原创不易,码字不易,还希望大家多多支持!话不多说, ...

  3. Android系统级技巧合集

    Android系统级技巧合集(随时更新) #转载请注明来源# 1.高通骁龙系列查看CPU体质等级 CPU体质,即为CPU在工作频率下的电压.同一批次的CPU体质各有不同,体质越高,代表该颗CPU可在更 ...

  4. IntelliJ IDEA必装插件以及SpringBoot使用小技巧合集

    IntelliJ IDEA必装插件 有不知道怎么安装的吗?File-->settings打开设置面板,找到plugins,输入想要安装的插件回车即可 1.背景图片 目前,IDEA支持设置背景图片 ...

  5. 62个Android Studio小技巧合集

    1书签(Bookmarks) 描述:这是一个很有用的功能,让你可以在某处做个标记(书签),方便后面再跳转到此处. 调用:Menu → Navigate → Bookmarks 快捷键: 添加/移除书签 ...

  6. Android Studio 小技巧合集

    本文翻译自 Android Studio Tips by Philippe Breault,一共收集了62个 Android Studio 使用小技巧和快捷键. 根据这些小技巧的使用场景,本文将这62 ...

  7. SpringBoot 使用小技巧合集

    原文:https://my.oschina.net/xiedeshou/blog/1926191 设置网站图标 原来我们在使用tomcat开发时,设置网站图片时,即icon图标时,一般都是直接替换ro ...

  8. linux -- Ubuntu 命令技巧合集

    http://www.nenew.net/UbuntuSkills.html#.E6.9F.A5.E7.9C.8B.E8.BD.AF.E4.BB.B6xxx.E5.AE.89.E8.A3.85.E5. ...

  9. 转:Andriod studio技巧合集

    1. 书签(Bookmarks) 描述:这是一个很有用的功能,让你可以在某处做个标记(书签),方便后面再跳转到此处. 调用:Menu → Navigate → Bookmarks 快捷键: 添加/移除 ...

随机推荐

  1. PHP设计模式

    设计模式总的分为三种,创建型模式.结构性模式.行为型模式 1.创建型模式 创建型模式为根据实际情况来创建对象,创建的模式又分为对象创建模式和类创建模式,对象创建模式会把对象创建的一部分在另一个对象中实 ...

  2. an interview question(4)

    版权声明:本文为博主原创文章,未经博主允许不得转载. 写这篇博客前请让博主先吐糟下自己的PC. i3+2G内存+开了一上午=C盘剩下0字节+打开VS2012花了半个小时+一晚上的心情不好 吐槽完PC, ...

  3. jQuery 遍历方法

    http://www.runoob.com/jquery/jquery-ref-traversing.html

  4. 概率dp专场

    专题链接 第一题--poj3744 Scout YYF I  链接 (简单题) 算是递推题 如果直接推的话 会TLE 会发现 在两个长距离陷阱中间 很长一部分都是重复的 我用 a表示到达i-2步的概率 ...

  5. SQL Server 2012 联机丛书离线安装

    昨日根据微软官网的方式安装SQL Server 2012 联机丛书报错,无法安装: 联机丛书下载位置及安装方式: 按照给出的方式安装,无法完成,错误如下:

  6. linux 系统下 ngnix 显示目录形式

    vi  /usr/local/nginx/conf/nginx.conf   #编辑配置文件,在server {下面添加以下内容: location  / { autoindex on; autoin ...

  7. Python anaconda links to GOMP_4.0 and throws error

    ImportError: /usr/progtools/anaconda2/bin/../lib/libgomp.so.1: version `GOMP_4.0' not found (require ...

  8. 磁盘文件系统Fat、Fat32、NTFS、exFAT的优缺点

    我们在Windows系统里格式化磁盘的时候,文件系统的选项里可以看到有“FAT”.“FAT32”.“NTFS”等选项,在对U盘或其他移动存储设备 格式化的时候还会出现“exFAT”选项,那么这四种磁盘 ...

  9. 加速编码的 JavaScript 库和工具

    JavaScript库是 一个提前写好的JavaScript文件库,它可以很容易的开发基于JavaScript的应用,特别是AJAX和一些其它的以web为中心的技术.运用JavaScript最基本的方 ...

  10. ajax中使用post传值数组array

    如果我们在data中想放入array的参数,根据在网上搜索的结果有如下方法,但是没有一个成功的……我还是贴出来,别人成功了,也许是我哪里不对,日后也许还有机会研究..在文章的最后贴出了转化为json的 ...