• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

vi, ex, view

vi, ex, view

vi  
ex  
view Screen-oriented text editor.
Line-oriented screen editor.  
Read-only version of vi.  
vi [-eFlRrSv] [-c <cmd>] [-t <tag>] [-w <size>] [<file1> <file2> …]
ex [-eFlRrSsv] [-c <cmd>] [-t <tag>] [-w <size>] [<file1> <file2> …]
view [-eFlRrSv] [-c <cmd>] [-t <tag>] [-w <size>] [<file1> <file2> …]
vi is a screen-oriented text editor; ex is a line-oriented editor. vi and ex are different interfaces to the same program. view is equivalent to vi -R, the read-only option to vi.
The following options are available:
-e Starts to edit in ex mode.
-F Doesn't copy the entire file when first starting to edit. Default is to make a copy in case someone else modifies the file during your edit session.
-l Starts editing with the lisp and showmatch options set.
-R Starts editing in read-only mode.
-r Recovers the specified file. If no file is specified, it lists the files that could be recovered. If no recoverable files with the specified name exist, vi starts editing as if the option has not been issued.
-S Runs with secure edit option set, which disallows all access to external programs.
-s Enters batch mode. Applicable only to ex. It is useful for running ex scripts.
-v Starts editing in vi mode.
-c <cmd> Executes <cmd> immediately after starting the edit session. It is especially useful for initial positioning in the file, but is not limited to positioning commands.
-t <tag> Starts editing at the specified <tag>.
-w <size> Sets the initial window size to <size> lines.
vi has two modes: command mode and input mode. Command mode is the initial and normal mode. Completion of the input mode returns the user to command mode. Pressing the <ESC> key ends a partial command.
Input mode is required to input some types of edits. Input mode is terminated by pressing <ESC>. Upon termination of input mode, the user is returned to command mode.
Some commands for moving around in a file:
h Moves the cursor one character to the left.
l Moves the cursor one character to the right.
j Moves the cursor one line down.
k Moves the cursor one line up.
<arrow keys> The arrow keys often also function properly.
<num>G Moves the cursor to the line number specified by <num>. If <num> is not specified, the cursor moves to the last line of the file.
Some commands for inputting text (input mode):
i Inserts text before the cursor.
a Appends new text after the cursor.
A Appends new text at the end of the line where the cursor is.
o Opens a new line below the line where the cursor is and allows the user to start entering text on the new line.
O Opens a new line above the line where the cursor is, and allows the user to start entering text on that new line.
Some commands for copying text:
yy Copies the line the cursor is on.
p Appends the copied line after the line the cursor is on.
Some commands for deleting text:
dd Deletes the line the cursor is on.
<num>dd Deletes <num> lines, starting with the line the cursor is on.
dw Deletes the word the cursor is on.
x Deletes the character the cursor is on.
Some other useful text manipulation:
r<x> Replaces the character the cursor is on with <x>.
J Joins the line the cursor is on with the line below it.
Some commands for pattern searching:
/<pattern> Searches forward in the file for <pattern>, starting with the location of the cursor.
?<pattern> Searches backwards in the file for <pattern>, starting with the location of the cursor.
n Repeats the last / or ? pattern search.
N Repeats the last / or ? pattern search in reverse.
Some commands to write the file:
:w<return> Writes the file back to the filename originally specified when vi was started.
:w <filename><return> Writes the file to the filename specified by <filename>.
Some commands to quit editing and exit vi:
:q<return> Exits vi. Refuses to quit if there are any unsaved modifications, or if the file is read-only.
:q! Exits vi, even if there are any unsaved modifications.
ZZ Exits vi, saving changes.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint