Archive for the ‘Software Development’ Category

Search and replace with VI

Wednesday, February 25th, 2009

To search and replace in VI, you have to use the “substitute” command, which looks like this: [range]s/[search_string]/[replacement_string]/[options] Examples To search and replace all occurrences of OLD with NEW, type: :%s/OLD/NEW/g To search and replace all occurrences of OLD with NEW and ask for confirmation with each substitution, type: :%s/OLD/NEW/gc To search and replace all [...]


How to change VIM’s working directory

Wednesday, February 25th, 2009

To change VIM’s current working directory, type: :cd NEW_DIRECTORY To display the current working directory, type: :pwd To change the working directory to that of the file that is open at the moment, type: :cd %:h


Customizing/disabling VIM’s matching parenthesis highlighting

Monday, February 23rd, 2009

I find vim’s matching parenthesis highlighting feature useful, but the default colors drive me nuts! It highlights the matching brace/bracket so vividly, I keep on getting confused with the cursor position! Here are a few solutions to this annoyance. Change the matching parenthesis font color and/or text-style To customize the font color, background color and/or [...]


How to remove ^M characters using VI

Sunday, June 29th, 2008

This is a quick tip for Linux/UNIX users who are familiar with the vi editor. Here’s how to remove those annoying ^M characters, that show up at the end of lines, in files that were created or modified in DOS/Windows. Open the file using vi, and type: :%s/[CTRL+v][CTRL+m]//g The [CTRL+v][CTRL+m] means holding down the CTRL [...]