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 快捷键: 添加/移除 ...
随机推荐
- Ubuntu 和 Redhat / Fedora 服务管理命令对比表(附Fedora16新的服务管理工具systemctl )
以 apache/httpd 服务作为例子 任务 Red Hat / Fedora Ubuntu Ubuntu (with sysv-rc-conf or sysvconfig) 立即启动/停止某服务 ...
- Selenium:元素等待的4种方法
1.使用Thread.sleep(),这是最笨的方法,但有时候也能用到而且很实用. 2.隐示等待,隐性等待是指当要查找元素,而这个元素没有马上出现时,告诉WebDriver查询Dom一定时间.默认值是 ...
- PBOC金融IC卡,卡片与终端交互的13个步骤,简介-第四组(转)
十:联机处理-可选项终端根据卡片行为分析的结果,执行对应的处理.若卡片响应联机,则终端发起联机操作.联机处理使得发卡行后台可以根据基于后台的风险管理参数检查并授权批准或拒绝交易.除了传统的联机欺诈和信 ...
- 转!!java事务的处理
java的事务处理,如果对数据库进行多次操作,每一次的执行或步骤都是一个事务.如果数据库操作在某一步没有执行或出现异常而导致事务失败,这样有的事务被执行有的就没有被执行,从而就有了事务的回滚,取消先前 ...
- iOS开发 滤镜的使用
iOS开发之滤镜的使用技巧(CoreImage) 一.滤镜的内容和效果是比较多并且复杂的 ,学习滤镜需要技巧 如下: 两个输出语句解决滤镜的属性选择问题: 1.查询效果分类中包含什么效果按住com ...
- centos6.7 mutlipath install script
#!/bin/bash if [ `id -g` != 0 ] ;then echo -e "\033[31m Please use root user\033[0m" exit ...
- Android NDK 初探,生成so文件以及调用so文件方法
因为最近业务上涉及安全的问题 然后有一些加密解密的方法和key的存储问题 本来想存储到手机里面,但是网上说一般敏感信息不要存储到手机Sdcard上 而且我这个如果从网络建立通信获取的话,又太耗时,所以 ...
- C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法
C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法? Request.params , Request ...
- 关于layui
之前用layer用了很长时间,感觉很好用,最近看到了layui的发布很想尝试尝试. 加入了挺多的功能,比如编辑器,上传,form表单等等.
- js中this的使用
this是Javascript语言的一个关键字. 它代表函数运行时,自动生成的一个内部对象,只能在函数内部使用.比如, function test(){ this.x = 1; } 随着函数使用场合的 ...