Vi Editor for PeopleSoft DBA

by Prashant on December 12, 2012

in General

 VI Editor commands for PeopleSoft DBA

Movement Commands


h, j, k, l Left, down, up, right


w, W, b, B Forward, backward by word
e, E End of word
(, ) Beginning of next, previous sentence
{, } Beginning of next, previous paragraph
[[, ]] Beginning of next, previous section


, $ First, last position of current line
^ First non-blank character of current line
+, - First character of next, previous line
H Top line of screen
M Middle line of screen
L Last line of screen
nH, nL Line n from top, bottom of screen


[Ctrl]F, [Ctrl]B Scroll forward, backward one screen
[Ctrl]D, [Ctrl]U Scroll down, up one-half screen
[Ctrl]E, [Ctrl]Y Show one more line at bottom, top of window
z[Enter] Scroll until line with cursor is at top of screen
z. Scroll until line with cursor is at middle of screen
z- Scroll until line with cursor is at bottom of screen


/pattern Search forward for pattern
?pattern Search backward for pattern
n, N Repeat last search in same, opposite direction
/, ? Repeat previous search forward, backward
fx search forward for character x in current line
Fx search backward for character x in current line
tx search forward for character before x in current line
Tx search backward for character after x in current line
; Repeat previous current-line search
, Repeat previous current-line search in opposite direction

Line Number

[Ctrl]G Display current line number
nG Move to line number n
G Move to last line in file
:n move to line number n

Marking Position

mx Mark current position as x
`x Move cursor to x
`` Return to previous mark or context
'x Move to beginning of line containing mark x
'' Return to beggining of line containing previous mark


Editing Commands


i, a Insert text before, after cursor
I, A Insert text at beginning, end of line
o, O Open new line for text below, above cursor


r Replace with next typed characer
~ Change between uppercase and lowercase
cm Change text block defined by movement command m (e.g., cw changes next word)
cc Change current line
C Change to end of line
R Type over characters
s Delete character and continue typing
S Delete current line and continue typing

Delete, Move

x Delete character
X Delete character to the left of the cursor
dm Delete text block defined by movement command m (e.g., dw deletes next word)
dd Delete current line
D Delete to end of line
p, P Put deleted text before, after cursor
"np Put text from delete buffer number n after cursor (for last nine deletions)


ym Yank (copy) text block defined by movement command m (e.g., yw yanks next word)
yy, Y Yank current line
"ayy Yank current line into named buffer a
p, P Put yanked text before, after cursor
"aP Put text from buffer a before cursor

Other Commands

. Repeat last edit command
u Undo last edit
U Undo changes to current line
J Join two lines
[Ctrl]L, [Ctrl]R Redraw screen

Examples of ex Equivalents

:d Delete lines
:m Move lines
:co or :t Copy lines
:.,$d Delete from current line to end of file
:30,60m. Move lines 30 through 60 after current line
:.,/pattern/co$ Copy from current line through line containing pattern to end of file


Invoking vi

vi file Invoke vi editor on file
vi file1 file2 Invoke vi editor on files sequentially
view file Invoke vi editor on file in read-only mode
vi -R file Invoke vi editor on file in read-only mode
vi -r file Recover file and recent edits after system crash
vi + file Open file at last line
vi +n file Open file at line number n
vi +/pattern file Open file at pattern
ex file Invoke ex editor on file from Unix


Other ex Commands

ex Commands

: Invoke ex from vi editor
:sh Create a new unix shell
[Ctrl]D Return to editor from shell
:! command Issue a unix command
:r newfile Read contents of newfile into current file
:r !command Read output of unix command into current file


:map x sequence Define keystroke x as a command sequence
:unmap x Disable map x
:map! x sequence Define x as command sequence invoked in insert mode
:unmap! x Disable insert mode map x
:ab abbr phrase Abbreviate phrase as abbr; when abbr is typed in insert mode, it expands into phrase
:unab abbr Disable abbreviation abbr

Setting Options

:set option Activate option
:set option=value Assign value to option
:set nooption Deactivate option
:set Display options set by user
:set all Display all options
:set option? Display value of option


Exit and Save Commands

ZZ Save file and quit
: x Save file and quit
:wq Save (“write”) file and quit
:w Save file
:w! Save file (overriding protection)
:30,60w newfile Save lines 30 through 60 as file newfile
:30,60w>> file Append lines 30 through 60 to file file
:w Save current buffer named file as
:q Quit
:q! Quit, discarding any changes
Q Quit vi and invoke ex
:e file2 Edit file2 without leaving vi
:e! file2 Discard changes to current file, then edit file2 without leaving vi
:n Edit next file
:e! Discard all changes since last save
:e# Edit alternate file


Special Symbols in ex

. Addressing symbol for current line
$ Addressing symbol for last line of file
# Alternate filename
% Current filename
! (after an ex command) override warning


Have any useful commands that you want to share with others. Post them below and help others.

Also Read:  How to Configure SES with Multiple PeopleSoft Instances

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: