Owner's manual

Example 2 Sample .exrc File
" arrow keys
map <Ctrl-V><up-arrow> k
map! <Ctrl-V><up-arrow> <Ctrl-V><Esc>ki
map <Ctrl-V><down-arrow> j
map! <Ctrl-V><down-arrow> <Ctrl-V><Esc>ji
map <Ctrl-V><right-arrow> l
map! <Ctrl-V><right-arrow> <Ctrl-V><Esc>li
map <Ctrl-V><left-arrow> h
map! <Ctrl-V><left-arrow> <Ctrl-V><Esc>hi
" Insert key
map <Ctrl-V><Insert> i
" Delete key
map <Ctrl-V><Delete> x
map! <Ctrl-V><Delete> <Esc>xi
" Page Up key
map <Ctrl-V><Page Up> <Ctrl-V><Ctrl-B>
map! <Ctrl-V><Page Up> <Ctrl-V><Esc><Ctrl-B>i
" Page Down key
map <Ctrl-V><Page Down> <Ctrl-V><Ctrl-F>
map! <Ctrl-V><Page Down> <Ctrl-V><Esc><Ctrl-F>i
The map command maps a vi command to a command key. The map! command performs the
same mapping for text input mode.
Create a Sample Edit File
Before you get started with the following examples of vi, you need to create a sample file to edit.
Create that file with the cat command as follows:
$ cat > my.file
You can use this text file
to experiment with vi.
<Ctrl-c>
Opening a File
The basic syntax for vi is the same whether you are creating a new file or opening an existing
file:
vi file
file is the name of either the new file you are creating or the existing file you are opening.
To open the file my.file, enter:
$ vi my.file
Your screen should look like the following:
You can use this text file
to experiment with vi.
~
~
~
~
~
~
~
"my.file" 2 lines, 46 characters
Getting Started 157