Why vi? Because it's available on all Unix and Linux systems and there will be times when you need to navigate and alter files and vi is available and accessible to you when nothing else is.
OPERATING INSTRUCTIONS!
To enter the vi editor, use the vi command followed by the name of the file you want to edit. If the file doesn't exist, it will be created for you before you leave the editor. If it does exist, the current contents will be loaded into the edit buffer for you. When you enter the vi command and press enter, you'll be presented with a screen that shows the first lines of the current file contents.
Stop at this point. The keyboard in front of you has been transformed from a tool you use to enter whole commands, words and sentences into a function keypad. Each time you press a single key, an action will be taken. You're in vi's command mode. Make sure your caps lock key is OFF. Let's try some commands.
j will move the cursor down 1 line
k will move the cursor up one line
h will move the cursor left one character
l will move the cursor right one character
If you type in a number before you press the letter key, then instead of moving one character, you'll move by the number you entered. Thus 20j will move you down 20 lines. You'll probably find that the direction keys on your keyboard also work in vi, but that doesn't always happen, so learn the letters. Hint: the four letters are in a line on the keyboard, the h that moves left is on the left and the l that moves right is on the right.
You want to delete a character?
- Move the cursor over it and press "x".
- To delete six characters, enter "6x".
To insert characters:
- Move the cursor to the character before the one you want to insert
- press "i"...this will take you into insert mode
- type in your extra text; this can even include new line characters.
- press the "esc" key to return from insert mode to command mode
the "a" key also enters insert mode, but the text is added after the cursor
It's vital that you understand the difference between command mode and insert mode. In insert mode, typing "Graham" will add the word into the edit buffer. In command mode, you'll:
- Jump the cursor to the last line of the text
- Replace the first letter on that line with "a"
- Try to move the cursor one left, which will ring the bell ....
If you forget which mode you're in, press the esc key and you can then be sure that you're in command mode!
That's bare-minimum vi; there are two other commands you'll need to be able to complete any edit, albeit the most basic.
To delete a line, move the cursor onto it and enter "dd".
CAPITAL letter Z twice to save and exit from vi. To save your work and exit from vi, ensure that you're in command mode and enter "ZZ".
COMMAND SUMMARY
The most basic
a append (add after cursor)
dd delete current line
h move cursor left
i insert (add before cursor)
j move cursor down
k move cursor up
l move cursor right
x delete a character
ZZ save (if necessary) and quit
and one more:
:e![enter] oops, I made a right mess of that. Restart the edit!
Much more you can do - see the manual pages, the thousands of other resources out there on the net
See also
Linux introduction
Please note that articles in this section of our
web site were current and correct to the best of our ability when published,
but by the nature of our business may go out of date quite quickly. The
quoting of a price, contract term or any other information in this area of
our website is NOT an offer to supply now on those terms - please check
back via
our main web site
Web Application Deployment - Linux -An Introduction For Users [73] - ()
[74] - ()
[152] - ()
[249] - ()
[430] - ()
[431] - ()
[593] - ()
[659] - ()
[679] - ()
[703] - ()
[710] - ()
[711] - ()
[749] - ()
[984] - ()
[1012] - ()
[1013] - ()
[1068] - ()
[1259] - ()
[1287] - ()
[1288] - ()
[1366] - ()
[1408] - ()
[1438] - ()
[1527] - ()
[1651] - ()
[1764] - ()
[1803] - ()
[1893] - ()
[1897] - ()
[1902] - ()
[1904] - ()
[2201] - ()
[2203] - ()
[2299] - ()
[2300] - ()
[2479] - ()
[2494] - ()
[2636] - ()
[2831] - ()
[3179] - ()
[3256] - ()
[3791] - ()
[3819] - ()
resource index - Deployment
Solutions centre home page
You'll find shorter technical items at
The Horse's Mouth and
delegate's questions answered at
the
Opentalk forum.
At Well House Consultants, we provide
training courses on
subjects such as Ruby, Lua, Perl, Python, Linux, C, C++,
Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer)
many questions, and answers to those which are of general
interest are published in this area of our site.