Monday, June 23, 2008

Using Vim + ctags for easy locating of "#define" variables

If you want to find where some variable is defined in C code, you can use:
Ctrl-]


in Vim editor. However, this does not work for "#define" variables until you execute:
ctags *.h *.c


on all .c and .h files that you want to tag. After that you can search for "#define" variable using Vim's Ctrl-] command. In order to return at the original position (before the search) press Ctrl-T.

Executing shell commands through Vim

If you don't want to terminate Vim to execute a shell command just type: :! shell_command. How cool is that?

Wednesday, February 27, 2008

Nice code printing with a2ps

a2ps --line-numbers=1 --columns=1 -R -T4 -f5 -o output.ps input.c







SwitchMeaning
line-numbersturn on/off line numbers
columnsnumber of columns on the page
Rportrait mode
T4TAB size is 4 spaces
f5font size
o stringoutput file name

Monday, November 19, 2007

Comment a block of source code using Vim editor

To easily comment a block of source code using Vim editor do following:
  1. Enter the block-wise visual mode (using ctrl+v command) and select desired block with h, j, k and l keys. Selecting the most left columns of the lines that you want to comment is sufficient, as well.
  2. Type shift+i to enter insert mode and move cursor to the beginning of the first line in selected block.
  3. Type // if you want to add C line comments (#, ", etc. depending of the used programming language syntax).
  4. Type Esc to leave the visual mode.
Characters (from step 3) will be added at the beginning of every line in the block.


The block-wise visual mode can be also used in other situations. For example, if you want to add certain text in the middle of several adjacent lines you should do previously explained routine on the block which begins at the position where you want to insert the text.

Enjoy using Vim editor.

Monday, November 12, 2007

Change the capitalization of text using Vim editor

To change the capitalization of characters in a word, line, paragraph, etc. using Vim editor do the following:
  1. select the text which you want to change (using v, ctrl-v or shift-v in the command mode)
  2. type ~
All uppercase characters is replaced with lowercase ones.
All lowercase characters is replaced with uppercase ones.

For example:
  • TREE becomes tree
  • Dog becomes dOG
  • fish becomes FISH
  • SomeStrangeText becomes sOMEsTRANGEtEXT

Enjoy using Vim!

Friday, August 25, 2006

My first post

On August, 24th 2006. I have opened my blog. In the world, 75 millions of people already use blogs. At the basketball world cup, we have been defeated by Argentina. Still, we have qualified for the next round.