13.8.1. Using ex editor commands

Editing in vi mode also enables you to access several ex commands. These are shown in Table 13.5 and Table 13.6.

When using ex commands in vi mode, whether using : or / commands, pasted text is applied at the : or / command regardless of the position of the cursor. Similarly, when working in s mode (substitute text at the $ sign), pasted text is applied at the $ sign regardless of the position of the cursor.

Table 13.5. ex commands supported in vi mode

Command

Function

:a

Append text after cursor.

:d

Delete current line. Use :.,$d to delete from the current line to the end of the file.

:e

Exit (warns of unsaved changes).

:e!

Exit without saving buffer contents.

:g

Change all occurrences of text on current line.

:n

Edit next file in buffer.

:q

Quit (warns of unsaved changes).

:q!

Quit without saving buffer contents.

:r file

Read file to specified position.

:s/str1/str2

Substitute str2 for str1 on current line. Use range to specify line numbers, for example :2,10s/int1/int2 or :1,$s/int1/int2. Use /g to make a global substitution.

:t

Search and move.

:w

Write buffer contents. This reports the full pathname, the number of lines and the size.

:w file

Write buffer contents to file. Edit file specified by file. Use range to specify line numbers to write, for example :2,10w file.

:x

Kill editor instance. This writes buffer contents and closes the Code window.

:y

Yank.

:e file

Edit file specified by file.

:wq

Write buffer contents and quit.

:set autoindent

Set indent to match previous line.

:set sw

Set shiftwidth for soft tabs.

:set all

Display list of customizing options.

:set nu

Display line numbers.

:set nonu

Do not display line numbers.

:set tabstop

Set tabstop size.

?

Search backwards in file.

/

Search forwards in file.

:

Begin in ex editor.

!

Execute a shell.

Table 13.6. Additional ex commands supported in vi mode

Command

Function

:cwd

Show or set local working directory. Local means local to this window only.

:cwd*

Set local working directory to that of the current file. Local means local to this window only.

:nw file

Open file in new standalone editor window.

:tfunc

Jump to named function. Can also use :tstr* to find a function name starting with str.

Copyright © 2003, 2004 ARM Limited. All rights reserved.ARM DUI 0234B
Non-Confidential