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:

    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.

来自为知笔记(Wiz)

时间: 2024-08-28 12:09:33

vi技巧合集的相关文章

Android系统级技巧合集

Android系统级技巧合集(随时更新) #转载请注明来源# 1.高通骁龙系列查看CPU体质等级 CPU体质,即为CPU在工作频率下的电压.同一批次的CPU体质各有不同,体质越高,代表该颗CPU可在更高的频率下稳定工作,且在相同频率下工作时功耗相比同批次体质差的CPU要控制得更好. 以搭载高通骁龙801的小米4(OS:第三方原生Android)为例,可在/sys下的文件中查找到描述该CPU体质的文件. 路径为:/sys/module/clock_krait_8974/parameters/ 在该

Xcode使用技巧合集

之前零零散散写了, 转了一系列Xcode使用相关的文章,包括调试技巧,快捷键等等,但是一直没有汇总.今天就专门开一篇合集,纪录自己接触过的一些技巧. 以后相关的主题都会在这里持续更新. iOS开发- Xcode常用快捷键 iOS开发准备篇-(4)Xcode基本操作 iOS开发准备篇-(5)Xcode调试技巧_1 ios开发准备篇-(6)Xcode调试技巧_2 ios开发准备篇-(7)Xcode调试技巧_3 iOS开发 - XCode Debugger中的Icon符号的意义 另外, 我参加了 20

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

前言 最近工作比较忙,事情也比较多.加班回到家都十点多了,洗个澡就想睡觉了.所以为了不断更太多天,偷懒写个小技巧合集吧.之后有时间都会进行文章更新的.原创不易,码字不易,还希望大家多多支持!话不多说,开始今天的技巧合集吧~ 设置网站图标 允许跨域访问 独立Tomcat运行 启动不设置端口 启动完成前进行业务逻辑 动态修改日志级别 热部署 自定义启动Banner 文字形式 图片形式 相关资料 总结 一点吐槽 最后 老生常谈 设置网站图标 原来我们在使用tomcat开发时,设置网站图片时,即icon

转:渗透测试工具实战技巧合集

转自:http://www.freebuf.com/sectool/105524.html   选择性的删了一部分内容 最好的 NMAP 扫描策略 # 适用所有大小网络最好的 nmap 扫描策略 # 主机发现,生成存活主机列表 $ nmap -sn -T4 -oG Discovery.gnmap 192.168.56.0/24 $ grep "Status: Up" Discovery.gnmap | cut -f 2 -d ' ' > LiveHosts.txt # 端口发现,

62个Android Studio小技巧合集

1书签(Bookmarks) 描述:这是一个很有用的功能,让你可以在某处做个标记(书签),方便后面再跳转到此处. 调用:Menu → Navigate → Bookmarks 快捷键: 添加/移除书签:F3(OS X) .F11(Windows/Linux); 添加/移除书签(带标记):Alt + F3(OS X).Ctrl + F11(Windows/Linux); 显示全部书签:Cmd + F3(OS X) .Shift + F11(Windows/Linux),显示所有的书签列表,并且是可

Android Studio 小技巧合集

写在前面 本文翻译自 Android Studio Tips by Philippe Breault,一共收集了62个 Android Studio 使用小技巧和快捷键. 根据这些小技巧的使用场景,本文将这62个小技巧分为常用技巧(1 – 28).编码技巧(29 – 49)和调试技巧(50 – 62),分成三个部分. 每个小技巧都配有 gif 动图,由于原图在 google photo 上,加载较慢,本文全部转存到七牛上了. 由于能力有限,翻译过程中难免有所疏漏,如发现错误或问题,请在评论中提出

渗透测试工具实战技巧合集

最好的 NMAP 扫描策略 # 适用所有大小网络最好的 nmap 扫描策略 # 主机发现,生成存活主机列表 $ nmap -sn -T4 -oG Discovery.gnmap 192.168.56.0/24 $ grep "Status: Up" Discovery.gnmap | cut -f 2 -d ' ' > LiveHosts.txt # 端口发现,发现大部分常用端口 # http://nmap.org/presentations/BHDC08/bhdc08-slid

常用技巧合集

1.截取长度${bean.title[0..21]} 2.时间戳转 格式化时间 String 转 Date 设置时间格式:<#setting datetime_format="yyyy-MM-dd HH:mm"/> 转换:${bean.createTime?number?number_to_datetime} 3.list是否为空 <#if list?exists>

vue 实践技巧合集

前言 本文纯属个人平时实践过程中的一些经验总结,算是一点点小技巧吧,不是多么高明的技术,如果对你有帮助,那么不胜荣幸. 本文不涉及罕见API使用方法等,大部分内容都是基于对vue的一些实践而已.由于涉嫌投机取巧,可能会带来一些不符合规范的副作用,请根据项目要求酌情使用. 多个页面都使用的到方法,放在 vue.prototype 上会很方便 刚接触 vue 的时候做过一件傻事,因为封装了一个异步请求接口post,放在 post.js 文件里面,然后在每个需要使用异步请求的页面引入 ``` impo