Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solaris for Dummies

Status
Not open for further replies.

Tybak

Vendor
Jun 26, 2003
3
US
Solaris 8
using telnet

I am new to UNIX. I just typed in

#vi /etc/nsswitch.conf

How do I exit?
How do I edit files?

Thanks in advance,
T
 
hmmmm... vi in 25 words or less: I recommend you get O'Reilly's book on vi. HP also wrote a good one, but I think it is out of print. vi will seem really klunky at first and you will probably hate it. But you know you are a real Unix when you can get around in vi and learn all that it can do.

Here are some hints to get you going:

to exit without saving:
:
q
!

to save and exit:
:
w
q
!

to change a word:
press l to move the cursor to the right until you are on the word. or press h to move the cursor to the left until you are on the word. then:
cw
<type in your changes>
Esc

to delete a word:
move the cursor as above. then:
dw

to insert text:
i
<type in the text>
Esc

to move a line up:
k

to move a line down:
j

To append at the end of a line:
A
<type>
Esc

 
One of the basic things to get used to with vi is that it has two modes; command mode (when it beeps at you a lot and seems to ignore what you want it to do) and insert mode (when what you type actually gets inserted into the document). Every time you hit &quot;Esc&quot; as described by Bi above you are returning to command mode.

When in command mode a lot of the commands are done in two steps, command then movement. For example, you could hit 'd' to delete some text, and then '}' to move to the end of the current paragraph, in which case it would remove from your current position to the end of the paragraph.

Here's a handy and fairly thorough vi reference:


Annihilannic.
 
The following is what I offer to anyone that asks how to drive VI, cut & paste it somewhere for later.

Enjoy, Laurie.


>--------- Help File For Basic VI ------------<

Command Mode

Escape to command mode (use the Esc key)

Exiting from VI

:wq! Write changes & Quit
:q! Quit without saving changes

Inserting Text

i Insert text before cursor
I Insert text at start of line
a Add text after cursor
A Add text at end of line
o Open new line below cursor
O Open new line above cursor
R Start replacing text

Changing Text

r Replace one character at cursor
s Substitute One Character
cw Change word
C Change to end of line
cc Change whole line
5cc Change 5 lines

Deleting text & lines

x Delete current character
X Delete previous character
dw Delete word
D Delete to end of line
dd Delete one entire line
5dd Delete 5 lines

How to move around

Up Arrow Move Up line by line
Down Arrow Move Down line by line
Left Arrow Move Left Char by Char
Right Arrow Move Right Char by Char

OR
h Left
J Down
k Up
l Right
/ Pattern search forward
? Pattern search backward
0 Move to start of line
$ Move to end of line

Correcting

u Undo last command
U Restore whole line

Debugging

:set number Turns on line numbers

>--------------- END ----------------<



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top