Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
If the file don't exists, vi will create a new one when you save it.
If the file exists, then you'll see it's content when vi loads.
So nothing to fear here.
Basics commands for VI are:
Code:
! -> force the command
q! means quit even if I don't have saved the file
w! means try to write the file even if i don't have the permission
i -> enter writing mode
esc -> go back from writing mode to command mode
number + G -> go to the line number x
G -> Go to the end of the file
o (the letter) -> Add a line after the cursor and enter edit mode
O (the letter) -> add a line before the cursor and enter edit mode
w -> write file
w! -> Force to write the file (if the content changed, or sometimes when permissions on the file are messed up)
q -> quit vi
wq -> write and exit vi
w!q -> try to force the file write even if the permissions are wrong, and exit
%s/aaa/bbb/gi -> replace every "aaa" with "bbb" through all the document
/ + aa-> Search "aa" from the current cursor position
dd -> delete the line under the cursor
d+ uparrow / down arrow -> delete the current line + next or previous one
u -> undo
You must hit "esc" to switch back from writing mode to command mode.
Remember that you need to be in command mode for those to work, and that command start with : .
So, to write the file when you are editing it, type the sequence to exit to command mode, write the file, and enter back in edit mode.
2 things: Try to use vim, it's more advanced. You may already use it when you type vi, it's distribution dependant.
If vi is too much, try nano. It's often installed by default, and it's operation mode is more like you are used to, for sure.
Remember than in command mode, you cannot write, and in writing mode, you must go back to command mode to do an action.
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 08-29-2007 at 05:50 PM..
|