0% found this document useful (0 votes)
112 views

"VI Editor Presentation": Accelerating Designs

The document provides instructions on how to use basic commands and functions in the vi text editor. It discusses how to open and view files, perform simple editing tasks like insertion, deletion and copying/pasting of text, and how to navigate and move the cursor around files using commands. The document is intended as a tutorial for newcomers to learn the basics of using the vi editor.

Uploaded by

hemantsaxna
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views

"VI Editor Presentation": Accelerating Designs

The document provides instructions on how to use basic commands and functions in the vi text editor. It discusses how to open and view files, perform simple editing tasks like insertion, deletion and copying/pasting of text, and how to navigate and move the cursor around files using commands. The document is intended as a tutorial for newcomers to learn the basics of using the vi editor.

Uploaded by

hemantsaxna
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

Accelerating designs

http://www.nsysinc.com

“VI Editor Presentation”


Roadmap

 How to open file in vi editor?


 Simple editing
 Basic Commands
 Commands to move

nSys Design Systems Confidential 2


HOW TO OPEN FILE IN VI EDITOR…
[1] On command line give the command:
vi file1 file2 .... filen
This will show up file1 in current window, and all other files are in buffers.
[2] Open a new file from an already opened vi file.
:vi filename
or
:e filename
The previous file(s) will still be there in the buffer.
[3] To view next file
:n[ext]<Enter>
[4] To view previous file
:N[ext]<Enter>
[5] To view last viewed file or buffer
:e#
nSys Design Systems Confidential 3
HOW TO OPEN FILE IN VI EDITOR

[6] To view a selected file from all opened files


:buffers
This shows list of all files opened along with their buffer numbers. Now
give the command
b[uffer]<buffernumber><Enter>
or
:e#<buffernumber><Enter>
e.g.:
:b1<Enter>
:e#1<Enter>
[7] To view all file(s) in seperate windows
:s[how]b[uffers]a[ll]

nSys Design Systems Confidential 4


SIMPLE EDITING IN VI EDITOR

 Enter Insert mode


i,a,I,A
na,ni -"n" is a number
 Open new line for editing
o,O

nSys Design Systems Confidential 5


BASIC COMMANDS…

DELETION
 Delete word(s)
dw, ndw
 Delete from present cursor position to end of line
D
 Delete a line
dd
 Deletes n lines starting from current line
ndd
 Deleting character
x,nx

nSys Design Systems Confidential 6


BASIC COMMANDS…

CHANGING TEXT
 Change word(s)
cw,ncw
 Change text from current cursor position to end of line
C or c$
 Change entire line
cc
 Change n number of lines
ncc
 Change text from present cursor location to final cursor position
after motion.
c{motion}

nSys Design Systems Confidential 7


BASIC COMMANDS…

COPYING TEXT
 Copy word(s)
dw, ndw
 Copy a line
yy
 Copy n lines starting from current line
nyy
 Copy n lines starting from current line to a named buffer
"[a-z]nyy -"n" is the no. of lines to be copied
 Copy text from present cursor location to final cursor position after
motion
y{motion}
e.g.1: "yG" deletes test fro present cursor location to end of file.
e.g.2: "y$" copy text from present cursor position to end of line.

nSys Design Systems Confidential 8


BASIC COMMANDS

REPLACEMENT AND SUBSTITUTION


 Replace with single character
r,nr
 Substitute with multiple characters
s,ns
 Substitute current line
S
UNDOING CHANGES
 u, U
REDO
 CTRL-R

nSys Design Systems Confidential 9


COMMANDS TO MOVE IN VI EDITOR…

 Word Movement (w,W,b,B,e,E,ge,gE)


w,W :Move the cursor to starting of next word.
b,B : Move the cursor to starting of previous word.
e,E : Move the cursor to end of next word.
ge,Ge : Move the cursor to end of previous word.
 Moving to top of file: gg, 1G
 Moving to end of file: G
 Moving to specific line number: linenumberG, :linenumber<CR>
e.g.: typing 33G will take the cursor to 33rd line.
 Scrolling around
CTRL-U,CTRL-B : page up
CTRL-D,CTRL-F : page down
CTRL-E : scroll up one line
CTRL-Y : scroll down one line
h,l,j,k

nSys Design Systems Confidential 10


COMMANDS TO MOVE IN VI EDITOR

 Moving to the start or end of a line


 The "$" command moves the cursor to the end of a line. If your
keyboard has an <End> key it will do the same thing.
 The "0" command (zero) moves to the very first character of the
line.
 The <Home> key does the same thing. In a picture:
 The "$" command takes a count, like most movement commands.
But moving to the end of the line several times doesn't make
sense. Therefore it causes the editor to move to the end of another
line.
 For example, "1$" moves you to the end of the first line (the one
you're on), "2$" to the end of the next line, and so on.

nSys Design Systems Confidential 11

You might also like