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
+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技巧合集的更多相关文章
- 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 快捷键: 添加/移除 ...
随机推荐
- CSS伪类和伪元素
一.伪类 CSS伪类用于向某些选择器添加特殊的效果,在W3规范中,CSS伪类有如下几个: CSS2.1 :active:向被激活的元素添加样式(激活是指点击鼠标那一下) :focus:向拥有键盘输入焦 ...
- Android 之surfaceView (画动态圆圈)
通过之前介绍的如何自定义View, 我们知道使用它可以做一些简单的动画效果.它通过不断循环的执行View.onDraw方法,每次执行都对内部显示的图形做一些调整,我们假设 onDraw方法每秒执行 ...
- C# 实现 Excel文件的数据导入
前台 <asp:FileUpload ID="fuFile" runat="server" /> 后台 public string GetExcel ...
- commons-io ProxyInputStream,ProxyOutputStream,ProxyReader,ProxyWriter
1.ProxyInputStream: A Proxy stream which acts as expected, that is it passes the method calls on to ...
- java打印Jni层log
在eclipse上新建jni工程可以参考:http://www.cnblogs.com/ashitaka/p/5953708.html 要在java层打印c的log必须引入这个头文件的宏定义: #if ...
- BIOS MCSDK 2.0 学习笔记(一)
MCSDK简介 BIOS MCSDK是为TI的高性能多核DSP提供的一套组件,包括: SYS/BIOS实时操作系统 Chip support libraries, drivers, and basic ...
- codeforces #369div2 B. Chris and Magic Square
题目:在网格某一处填入一个正整数,使得网格每行,每列以及两条主对角线的和都相等 题目链接:http://codeforces.com/contest/711/problem/B 分析:题目不难,找到要 ...
- KMP算法解析(转自图灵社区)
KMP算法是一个很精妙的字符串算法,个人认为这个算法十分符合编程美学:十分简洁,而又极难理解.笔者算法学的很烂,所以接触到这个算法的时候也是一头雾水,去网上看各种帖子,发现写着各种KMP算法详解的转载 ...
- JavaScript模块化
1.commonjs 导入: var math = require('math'); math.add(2,3); // 5 导出: module.exports={} 应用会停止并等待加载 2.AM ...
- C++语法-指针 (1)
<C++程序设计> 谭浩强 清华大学出版社 2016-08-03 1.P167 一般的C++编译系统为每个指针变量分配4个字节的存储单元,用来存放变量的地址. 2.P169 .cpp文件 ...