vi技巧合集
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:
%s/\<printf\>/PRINTF/gc
match the current line to last line of file
.,$s/printf/PRINTF/gc
match the current line to the next two line of file
.,+2s/printf/PRINTF/gc
replace word contain /, eg. printf->//print
:s!printf!//printf!gc
text selection
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:
%s/\<printf\>/PRINTF/gc
match the current line to last line of file
.,$s/printf/PRINTF/gc
match the current line to the next two line of file
.,+2s/printf/PRINTF/gc
replace word contain /, eg. printf->//print
:s!printf!//printf!gc
链接地址
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
: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+Vto select the first column of text in the lines you want to comment. - Then hit
shift+iand type the text you want to insert. - Then hit
Escwait 1 second and the inserted text will appear on every line.
vi技巧合集的更多相关文章
- javascript技巧合集
转http://www.blogjava.net/zhaochengming/archive/2010/04/09/317837.html http://www.cnblogs.com/fxgachi ...
- SpringBoot | 番外:使用小技巧合集
前言 最近工作比较忙,事情也比较多.加班回到家都十点多了,洗个澡就想睡觉了.所以为了不断更太多天,偷懒写个小技巧合集吧.之后有时间都会进行文章更新的.原创不易,码字不易,还希望大家多多支持!话不多说, ...
- Android系统级技巧合集
Android系统级技巧合集(随时更新) #转载请注明来源# 1.高通骁龙系列查看CPU体质等级 CPU体质,即为CPU在工作频率下的电压.同一批次的CPU体质各有不同,体质越高,代表该颗CPU可在更 ...
- IntelliJ IDEA必装插件以及SpringBoot使用小技巧合集
IntelliJ IDEA必装插件 有不知道怎么安装的吗?File-->settings打开设置面板,找到plugins,输入想要安装的插件回车即可 1.背景图片 目前,IDEA支持设置背景图片 ...
- 62个Android Studio小技巧合集
1书签(Bookmarks) 描述:这是一个很有用的功能,让你可以在某处做个标记(书签),方便后面再跳转到此处. 调用:Menu → Navigate → Bookmarks 快捷键: 添加/移除书签 ...
- Android Studio 小技巧合集
本文翻译自 Android Studio Tips by Philippe Breault,一共收集了62个 Android Studio 使用小技巧和快捷键. 根据这些小技巧的使用场景,本文将这62 ...
- SpringBoot 使用小技巧合集
原文:https://my.oschina.net/xiedeshou/blog/1926191 设置网站图标 原来我们在使用tomcat开发时,设置网站图片时,即icon图标时,一般都是直接替换ro ...
- 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. ...
- 转:Andriod studio技巧合集
1. 书签(Bookmarks) 描述:这是一个很有用的功能,让你可以在某处做个标记(书签),方便后面再跳转到此处. 调用:Menu → Navigate → Bookmarks 快捷键: 添加/移除 ...
随机推荐
- 你的指纹还安全吗? - BlackHat 2015 黑帽大会总结 day 2
你的指纹还安全吗? 0x03 FINGERPRINTS ON MOBILE DEVICES: ABUSING AND LEAKING speaker是来自FireEye的Wei Tao和Zhang ...
- application、viewstate、纯HTML提交方式
Application - 全局公共变量组 存放位置:服务端 所有的访问用户都是访问的同一个变量 声明周期:永久 用法同session类似 viewstate-病例 因为http的无状态性,需要记录上 ...
- Struts2中Action的使用(Struts2_Action)
一.Action概要 二.动态调用 三.通配符(规则:*_*等价于{1_2}) 四.获取参数 1 1.方式一:逐个获取(推荐使用) 2 package com.aaron.action.param ...
- 从github获取代码
以duilib为例: 1 建立一个文件夹,右键 git bash here. 2 git init 3 git clone https://github.com/duilib/duilib.git
- Windows下 Maven 使用 阿里云镜像配置
新建或者修改文件: C:\Users\user\.m2\settings.xml <settings xmlns="http://maven.apache.org/SETTINGS/1 ...
- wmware 怎么 跟主机相互通信
VMnet1和VMware8其实就是软件模拟出来的两块网卡提供DHCP服务,两块网卡对应VMware的两种不同的模式VMWare提供了三种工作模式,它们是bridged(桥接模式).NAT(网络地址转 ...
- 数字图像处理作业使用OpenCV - 使用笔记
数字图像处理作业的输入图像全部都是灰度图像,所以汇总一下自己遇到的问题答案. OCV的图像容器是Mat<typename>,可以用imread(filename)读取图像,filename ...
- PE文件学习系列笔记四-C++实现PE文件的分析
合肥程序员群:49313181. 合肥实名程序员群:128131462 (不愿透露姓名和信息者勿加入) Q Q:408365330 E-Mail:egojit@qq.com 综述: 首 ...
- 记一次log4j日志文件输出错误的解决
log4j错误信息:log4j:ERROR Failed to rename [D:/logs/wmts_] to [D:/logs/wmts_2015-12-21.log ]. 起因:部门网站使用B ...
- [HTML/CSS] ul元素居中处理
CSS: <style type="text/css"> #nav_sub_page { text-align: center; width: 80%; } #nav_ ...