shuaizki

仓库 随笔 数据 java相关

移动的命令

L 移动到屏幕的末端
20| 移动到第20列(囧,之前都是20->的)

replace

之前用0,$g/old/s//new/g用惯了,其实全局替换的话还是用
%s/old/new/g比较好,手指可以偷偷懒
%s/old/new/gi的话是case unsensitive, gc的话就是需要confirmation
另外s/old/new/替换第一个遇到的old, 而后面加个g的话替换该行所有遇到的old
g/string/d 的话则是删除含有string的行
v/string/d 是删除不含string的行
另外ctrl-a 和 ctrl-x分别是increment num 和decrement num简直是装逼必备的命令

case operation

Vu->lowercase line, V是选中当前行
VU->uppercase line
g~->invert case veU->uppercase a word, 这个指令是这么一回事,v是选择模式,e会选中当前的词,u是lowercase,U是uppercase
ve
->把一个词的case翻转,如果单用~的话,是把光标下的char变成invert case
剩下的一些暴长无比的指令根本就没必要记了。只需记住用e选择一个word,U是将当前选中的区域uppercase,u是lowercase,而~是invert
不过我比较好奇的是为嘛图片里提到的set first letter of each word to uppercase 在我的vim里没有用

read/write files

一些比较上档次的文件读写命令:
1,n w outfile 1到n行的line写到outfile里
:1,n >> outfile 的话可自行脑补
:r infile insert the content of in file, 有了这个就不用每次很傻x的vs然后copy了
:23r infile insert the content of infile under line 23

file explorer

基本没用过这货。。。
:e . 打开集成的file explorer
:Sex ^ ^, split window and open explorer
:Sex! ^ ^, vertically split window and open explorer
:ls list buffers
:args list files :grep expression return a list of reg matching files :gf open file name under cursor
目测最有用的可能是Sex和gf

interact with linux

:sh temporary returns to linux

tabs/windows

完全没用过这堆东西
:tabnew create a new tab
gt next tab
:tabfirst tablast
:tabdo command execute a command in all tabs
:tab ball puts all open files in tabs
:new abc.txt edit abc.txt in new tab

auto-completion

ctrl+n ctrl+p complete word, n是next的意思, p是prev的意思
ctrl+x ctrl+l complete line
:set dictionary=dict define dict as a dicitonalry 这个好像有点意思,这样话是不是可以把自己写的工作做个dictionary
ctrl+x ctrl+k complete with dicitonary

abbreviation

好像是个比较好玩儿的属性
:ab word word will be expanded to this
:una word
:abc clear all abbreviations

indent

=% indent code between parenthesis