My Coding Experience with AI LLMs evolve so fast. I feel it’s worth recording my current thoughts on how this technology changes my day to day experience in writing code.
Update Vim with Bells and Whistles There is a lot happening in tech, and AI is apparently replacing developers in batches, according to all kinds of “authoritatives”. The reason the singularity is behind schedule, and we still have jobs, must because AI is using Emacs. LOL.
[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 […]
vimGdb 又回到了用VIM的状态。刚装起来了vimGdb,vim的各种gdb插件还是这个比较顺手。唯一的不足之处是vimGdb需要给源码打一个Patch。 vim最新的稳定版本是7.3,对应的vimGdb在这里 larrupingpig/vimgdb-for-vim7.3 下面的说明比较清楚了,需要注意的是vim的源码必须是 vim-7.3.tar.bz2 这个包,如果是从最新的库里checkout的代码会和patch不匹配。 比如在~/Temp下有 vim-7.3.tar.bz2 vimgdb-for-vim7.3.tar.gz 解压 $tar xvf ./vim-7.3.tar.bz2 $tar xvf ./vimgdb-for-vim7.3.tar.gz 打patch $patch -p0 < ./vimgdb-for-vim7.3/vim73.patch 编译 $cd ./vim73 $./configure --enable-gdb $make $sudo make install 把./vimgdb-for-vim7.3/vimgdb_runtime/里面的文件拷贝到~/.vim/下 推荐使用Pathogen管理plugin,会比较方便一点 在~/.vimrc里增加一句 source ~/.vim/macros/gdb_mappings.vim 然后就OK了。编译代码的时候用-gstabs+让gcc把调试的信息加上去。 具体请参看vimGBD的文档。这里也行:gdb.txt P.S. 大神们真无聊啊,居然把vim移植到iOS上去了...Vim iOS
[Tips]2011-10-30 vim的paste mode 我们会遇到这样的情况: 需要从Vim之外的其它程序里拷贝一大段文字,然后在Vim里粘贴。 一般的,启动vim之后,按i进入插入模式 (Insert Mode),然后粘贴就行了。 但是当Vim的配置越来越多,插入模式下粘贴大段文字时可能会遇到各种诡异的情况。 因为这个时候的粘贴就相当于手动输入这些内容,于是各种映射 (Mapping) 就被触发了…. :set paste 可以启动一种paste模式,这个时候各种Mapping会被无视,各种自动缩进也无效。和在记事本里粘贴效果一致。 paste命令也符合Vim的通常规范 :set nopaste 可以关掉它。
[Tips]2011-10-19 两个Vim的小技巧 :] 其实就是两个正则表达式,刚好今天用到了,就记下来。 1. 有多行文本,其中有几行是URL,要保留这几行URL,其它的行删掉。 :g!/:\/\//d g本来是用来做grep类似的事情的,:g/pattern 会显示出符合pattern的所有行 惊叹号!表示相反,就是指选中的行是不符合pattern的。后面的/d是表示删掉选中的行。 2. 有多行文本,每行都是类似这样的 keyA=valA&keyB=valB&keyC=valC 现在要交换key和val的位置,变成 valA=keyA&valB=keyB&valC=keyC :%s/\=\/\2=\1/gi %s是全局替换,这个比较常用了。\是不太常用的anchor字符(锚字符),分别表示word的开始和结束。 \(..\)也比较常用了,可以保存匹配结果。\w*表示一个或多个word字符。 word字符包括a-zA-Z _ 和 0-9 :]