extremely useful VIM tips

Well, you can delete the searched pattern this way:
:%s///gc
And you can delete the whole line with the searched pattern this way:
:g//d

another dirty trick for windows batch file

I shared in another earlier post a dirty tick to change directory to where the batch file is located; this is useful when you want to run your batch file from any directory prompt;

C:\xxxx\yyy\anything\myscript.bat

The trick is one single line:

cd /d %0\..



However, this has some limitations.

It is more often than not when you release your batch file in a network shared directory, and your end user want to run directly from there (i.e. without copying to local disk); if the drive is not mapped to the local system, you will be caught in surprise when running the above line.


The error is "CMD does not support UNC paths as current directories";


The hack is simple -- another magic line:


pushd %~dp0

failed design


a wall socket with two receptacles, however, no enough spaces in between.


a "Function" key which will always be mistaken as CTRL.


a "smart" design which winds 2 pieces together to save space, however, very fragile


a notebook which is very hard to write on the left side


a toilet seat (think....)


even harder one (think...)


a RJ45 socket which always blocks mouse movement


a airplane passenger seat where there is no place for legs




a shirt which customer always have to cut the brand labels

usage tips for Linux

# to search for a key word in files with certain extension
find . -iname "*.cc" -exec grep -Hin "thekeyword" {} \;
# -i to ignore case
# -H will print out the file name which matches to the filter
# -n will print out the matching line number

#if you want to use some filter containing escape char, use single quote
find . -name "*.cc" -exec grep 'setData(\"Pass'  {}\;

#to count the number of occurrence of certain word/pattern in vim
:%s/pattern//gn

# to count number of files in a directory
find . -type f | wc -l

# to change command prompt to { $user_name+@+$hostname +":" + $cwd> }
set prompt="\n%{\033[0;32m%}%n@%m:%{\033[0;33m%}%~%{\033[1;30m%}>%{\033\[1;37m%} "

# to use backspace to delete
stty erase ^H

# to pipe error and cout to file; for tcsh and csh only
./genKB_DA.sh >& ./log.txt

# about FTP downloading
use 'hash' to show download progress
use 'prompt' to turn off the 'y/n' prompt which blocks mget

# to check linux kernel version
uname -r

# to check red-hat version
cat /etc/redhat-release

# log in first as 'test' user, and then type the following to allow any user to access current x11 display
xhost +localhost

# to batch delete files based on strings in a file
xargs rm < ../fxxTN1.txt