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. 淘宝网触屏版 - 学习笔记(0 - 关于dpr)

    注:本文是学习笔记,并不是教程,所以会有很多我不理解或猜测的问题,也会有不尽详实之处,望见谅. 对于pc端网页设计师来说,移动端的网页制作,我之前只是简单的加了一个 <meta name=&qu ...

  2. antd 学习

    1,react中文文档http://reactjs.cn/react/docs/thinking-in-react-zh-CN.html 2,antd文档 https://ant.design/doc ...

  3. HBase 数据读写流程

    HBase 数据读写流程 2016-10-18 杜亦舒 读数据 HBase的表是按行拆分为一个个 region 块儿,这些块儿被放置在各个 regionserver 中 假设现在想在用户表中获取 ro ...

  4. JOIN关联表中ON,WHERE后面跟条件的区别

    select * from td  left join (select case_id as sup_case_id , count(*) supervise_number from  td_kcdc ...

  5. nginx学习记录/2016.11.14

    nginx(engine X)是一个高性能的web服务器和反向代理服务器以及电子邮件代理服务器 由俄罗斯的程序设计师Igor Sysoev所开发 nginx+tomcat实现负载均衡 参考地址:htt ...

  6. python——线程与多线程进阶

    之前我们已经学会如何在代码块中创建新的线程去执行我们要同步执行的多个任务,但是线程的世界远不止如此.接下来,我们要介绍的是整个threading模块.threading基于Java的线程模型设计.锁( ...

  7. JAVA 线程中的异常捕获

    在java多线程程序中,所有线程都不允许抛出未捕获的checked exception(比如sleep时的InterruptedException),也就是说各个线程需要自己把自己的checked e ...

  8. Mybatis + Mysql 插入数据时中文乱码问题

    近日跟朋友一起建立一个项目,用的是spring+mybatis+mysql. 今天碰到一个mybatis向mysql中插入数据时,中文显示为'???'的问题,拿出来说下. 对于数据库操作中出现的中文乱 ...

  9. [HTML/HTML5]9 使用表单

    9.1  创建基本表单 表单都具有相同的基础结构.即它都包含表单的的开始标记<form>和结束标记</form>.<input>控件和处理表单的方法.form元素包 ...

  10. java实现的类和表持久化

    //映射的过程: package com.ly.orm; import java.lang.reflect.Field; import java.util.ArrayList; import java ...