Home arrow BrainDump arrow Page 3 - A Look at the VI Editor

Cursor motion/movements - BrainDump

VI is the widely used text editor in UNIX operating systems. I have had the chance to use the VI editor in the Solaris and Linux operating systems. In this article we are going to learn how to use the VI editor.

TABLE OF CONTENTS:
  1. A Look at the VI Editor
  2. Saving and Closing a file
  3. Cursor motion/movements
  4. Undo editing
By: Mamun Zaman
Rating: starstarstarstarstar / 9
August 07, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

To move your cursors in VI use the following commands (a long list!).

h

Move left

j

Move down

k

Move up

l

Move right

w

Move to next word

W

Move to next blank delimited word

b

Move to the beginning of the word

B

Move to the beginning of blank delimited word

^

Moves to the first non-blank character in the current line

+

Moves to the first character in the next line

-

Moves to the first non-blank character in the previous line

e

Move to the end of the word

E

Move to the end of blank delimited word

(

Move a sentence back

)

Move a sentence forward

{

Move a paragraph back

}

Move a paragraph forward

0 or |

Move to the beginning of the line

$

Move to the end of the line

:n

Move to nth line of the file

For jumping to the beginning of the document use [[, and use ]] to jump to the end of the document.

Deleting texts: To delete content use d and x. Use x for deleting character to the right of the cursor. Use d with the above operands (motion/movement operands) for deleting. To delete a word use dw (next word). Delete is basically cut, i.e. you can paste the deleted contents. The following are some other delete commands.

x

Delete character to the right of cursor

nx

Deletes n characters starting with the current one; omitting n deletes current character only

X

Deletes the character to the left of cursor

nX

Deletes the previous n characters; omitting n deletes the previous character only

D

Delete to the end of the line

D$

Deletes from the cursor to the end of the line

dd or :d

Deletes the current line

ndw

Deletes the next n words starting with the current word

ndb

Deletes the previous n words starting with the current word

ndd

Deletes n lines beginning with the current line

:n,md

Deletes lines n through m

Tips: You can edit multiple lines better if you know the line numbers. To show line numbers use the following command.

:set nu

For example, to go to line number 5 use :5



 
 
>>> More BrainDump Articles          >>> More By Mamun Zaman
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

BRAINDUMP ARTICLES

- Apple Founder Steve Jobs Dies
- Steve Jobs` Era at Apple Ends
- Google's Chrome Developer Tool Updated
- Google's Chrome 6 Browser Brings Speed to th...
- New Open Source Update Fedora 13 is Released...
- Install Linux with Knoppix
- iPad Developers Flock To SDK 3.2
- Managing a Linux Wireless Access Point
- Maintaining a Linux Wireless Access Point
- Securing a Linux Wireless Access Point
- Configuring a Linux Wireless Access Point
- Building a Linux Wireless Access Point
- Migrating Oracle to PostgreSQL with Enterpri...
- Demystifying SELinux on Kernel 2.6
- Yahoo and Microsoft Create Ad Partnership

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: