The most basic functionality of an editor, is to move the cursor around in the text. Here are more movement commands.
h move the cursor one space to the left j move one line down k move one line up l move one line right Some implementations also allow the arrows keys to move the cursor. w move to the start of the next word e move to the end of the next word E move to the end of the next word before a space b move to the start of the previous word 0 move to the start of the line ^ move to the first word of the current line $ move to the end of the line <CR> move to the start of the next line - move to the start of the previous line G move to the end of the file 1G move to the start of the file nG move to line number n <Cntl> G display the current line number % to the matching bracket H top line of the screen M middle line of the screen L bottom of the screen n| more cursor to column n
The screen will automatically scroll when the cursor reaches either the top or the bottom of the screen. There are alternative commands which can control scrolling the text.
<Cntl> f scroll forward a screen <Cntl> b scroll backward a screen <Cntl> d scroll down half a screen <Cntl> u scroll down half a screen
The above commands control cursor movement. Some of the commands use a command modifier in the form of a number preciding the command. This feature will usually repeat the command that number of times.
To move the cursor a number of positions left.
nl move the cursor n positions left
If you wanted to enter a number or spaces in front of the some text you could use the command modifier to the insert command. Enter the repeat number then followed by the space then press .
ni insert some text and repeat the text n times.
The commands that deal with lines use the modifier to refer to line numbers. The is a good example.
1G Move the cursor to the first line.
vi has a large set of commands which can be used to move the cursor around the file. Single character movement through to direct line placement of the cursor. vi can also place the cursor at a selected line from the command line.
vi +10 myfile.texThis command opens the file called myfile.tex and places the cursor 10 lines down from the start of the file.
Try out some of the commands in this section. Very few people can remember all of them in one session. Most users use only a subset of the above commands.
You can move around, so how do you change the text?