My Tech notes: Useful VI Commands For Linux Beginners Read on
Subscribe

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Thursday, February 12, 2009

Useful VI Commands For Linux Beginners Read on

useful vi commands for Linux beginners

1) To open two files in single window of vi editor
a) vi a.c
b) give the following command in vi editor to open b.c file
:sp b.c
c) Now vi editor contain two files in each half screen. TO switch
between two files use ctrl+ww.


2)Replacing a text
a) vi a.c
b) In a.c file, replace printf with printk using follwing command
:%s/printf/printk
This will replace only first occurrence of printf in each line.
:%s/printf/printk/g
The above command will replace all printf words in entire
file with printk.
:%s/printf/printk/gc
The above command will ask confirmation.
:s/printf/printk
This commamnd will replace in current line.

3)setting auto indentation:

In home directory create .exrc file add the following commands
:set nu
:set cindent

:set cindent will do indentation in C
4) To open a man page of a system call from vi editor
a) vi a.c
put the cursor at system call and press shift+k

5) commands:

G : to goto endline in vi
X : delete the character
J : To join two lines
DW : Delete the Word
/str : search down for string
?str : search up for string

1 comment:

Felipe said...

Great job! I have subscription to your rss.

Post a Comment