Tag: vim

[Vim]用行号参与替换

一个小技巧。Vim有好处千种,”替换”只是其中一个。 除了强大的正则表达式,\=也是一个好用的工具。 比如要生成这么一个文件 This is number 1 This is number 2 This is number 3 This is number 4 This is number 5 This is number 6 This is number 7 This is number 8 This is number 9 This is number 10 方法当然有很多。用\=可以这么做: 先输入一行 This is number X 复制出另外9行 yy9p 得到 This is number

Linux Tips (1)

这里记录一些小技巧,比较杂。 1. bash下,x{a,b}会被展开为xa xb,很适合文件备份。 如果你要复制一份a.txt作为备份,到a.txt的路径又太长了,这么写比较方便。 cp /a/long/long/long/path/to/file/a.txt{,bak} 2. vim下,要把某些内容替换成为行号,可以用\=line(“.”)来处理。“.”用来连接行号和其它内容。 :%s/xxxx/\=line(".") . " "/g 3. bash脚本下,如果要写多行到文件里,可以用 cat > file

Project-Specific Vim Configuration

Usually, we have our own vim configuration in the file ~/.vimrc What if we want one for our project? For example, we are working on certain project which needs to read in a tags file. Well, here is a possible solution. You put a line at then end of your ~/.vimrc file source ./.project.vim Then