Using Vi

What is Vi?

Vi (pronounced vee-eye) is a text editor available on Super Computing Wales and virtually all Linux and Unix based computers. It was originally developed by Bill Joy in 1976 while he was at the University of California, Berkeley. Vi was designed to run on remote terminals over very slow connections and is known as the “visual editor”. Vi is part of the Linux standard base so you can guarantee that it will be installed on other Linux systems you may have access to.


Using Vi

To use Vi on Super Computing Wales you must logon to a head node such as You can only use it in terminal mode. To logon to Super Computing Wales you can use PuTTY. Please read the documentation before installing, and note that you can download PuTTY for free and install it on your computer.


Getting Started

To begin editing a new file type “vi” at the command prompt
Then type “i” to change to insert mode and begin typing
Then press the <Esc> key when you are done typing
Then type “:w path/to/file” and hit enter to save the file
Then type “:q” to quit vi


Starting Vi

virun vi
vi myfile.txtrun vi and open myfile.txt
vimrun vim
vim /home/user/myfile.txtrun vim and open /home/user/myfile.txt

Leaving Vi

ZZquit vi and write current file
:qquit vi
:wqwrite current file and quit
:q!quit vi and do not write current file


File Operations

:e /home/user/myfile.txtedit myfile.txt (tab completion works)
:w /home/user/myfile.txt

write myfile.txt (tab completion works)
:wwrite open file



Keyreturn to command mode
ichange to insert mode before current cursor position
achange to insert mode after current cursor position
ochange to insert mode but start a new line below current cursor


Cursor Operations

[repeat]wmove forwards [repeat] words
[repeat]bmove backwards [repeat] words
^move to the beginning of the line
0move to the beginning of the line
[repeat]fmove forwards to the [repeat] instance of
[repeat]Fmove backwards to the [repeat] instance of
[number]Gmove to line [number]
Hmove to the home line (first line on the screen)
Mmove to the middle line (on the screen)
Lmove to the last line (on the screen)
(move backwards one sentence
)move forwards one sentence
{move backwards one paragraph
}move forwards one paragraph


Edit Operations

[repeat]dwdelete (cut) [repeat] words
[repeat]dddelete (cut) [repeat] lines
d$delete (cut) to end of line
dGdelete (cut) to end of file
[repeat]ywyank (copy) [repeat] words
[repeat]yyyank (copy) [repeat] lines
pput (paste)


Search and Replace

[repeat]/search forwards to the [repeat] instance of
:s//search and replace the first instance of with
on this line
:s///gsearch and replace all instances of with > on this line
:%s///gsearch and replace all instances of with string> in this file


Getting Help




man vi – command line documentation
Learning the Vi and Vim Editors, Seventh Edition,



You can download a version to run on your local workstation from