riedquat - valueable resource for those who seek.
Home Blog Technical Reports Art Articles RapiDocs Coding Bugs Links Reviews Projects: CherBot Daimonin Gridarta

Cher's Tips and Tricks

Simple Code Reformatting

The Vim editor has some really nice features. For reformatting code, we will use the following features:

Simple code reformatting can be useful in various places:

Retabbing (replacing tabs with spaces)
ex -s -c "set et ts=4 | bufdo! retab | w" -c "q" $(find client server -name "*.c" -or -name "*.h")
Removing all trailing whitespace
ex -s -c 'bufdo! %s/\s\+$//e | w' -c "q" $(find client server -name "*.c" -or -name "*.h")
Retabbing and removing all trailing whitespace in a single command line
ex -s -c 'set et ts=4 | bufdo! retab | %s/\s\+$//e | w' -c "q" $(find client server -name "*.c" -or -name "*.h")

Using kdiff3 as 3-way-merge-tool for subversion

Create the following shell script. Put it somewhere in the system. I've stored it at /home/cher/bin/kdiff3.sh.

#!/bin/bash
kdiff3 ${10} ${9} ${11} -o ${10}.merged
cat ${10}.merged
rm ${10}.merged

Now change ~/.subversion/config to include the following line in the section [helpers]:

diff3-cmd = /home/cher/bin/kdiff3.sh
 . 
..: