[Novalug] how do you get out of visudo

Jeff Stoner leapfrog at freeshell.org
Wed Dec 3 11:15:01 EST 2008


On Tue, 2 Dec 2008, Nino Pereira wrote:

> I almost never use vi, or vim, or visudo. So, I continually
> forget how to store what you have just edited.
>
> I did vaguely remember that you can start editing in vi or
> its analogues when you do 'i'. And, there's also a command
> 'ZZ'. But, how do you get out of vi or vim or visudo?

[Note: all this applies to VIM - Vi IMproved, not a specific vendor's 
version of vi although they're very similar]

vi operates using 2 modes, editing mode (you change the contents of the 
editing buffer) and command mode (you send commands to vi.) When you start 
vi, you are in command mode and you have to give it a command to go into 
editing mode, such as i (insert at the cursor position), A (append to the 
end of the current line), o (insert a new line under the current line) and 
O (insert a new line above the current line.)

To exit editing mode and go into command mode, press the Escape key. Some 
commands require more than one key sequence and if you mistakenly start a 
command sequence and get "lost" press the Escape key 2 or more times. 
Don't worry if you press it 5 or 6 times, Bram Moolenaar won't jump out of 
the screen and slap you.

In command mode, commands can be single or multiple-letter/number 
sequences. Here are some helpful command sequences:

:q! = discard any changes and quit
:q = quit only if no changes were made
:w = write out the buffer (save)
:x = write out the buffer and exit
:wq = write out the buffer and quit
ZZ = write out the buffer and quit
:1 = go to the first line in the buffer
G = go to the last line in the buffer
J = join the current line with the line below it
b = move to the beginning of the current or previous 'word'
e = move to the end of the current or next 'word'
~ = reverse the case of the letter at the cursor then advance to the next 
character

The h, j, k and l commands can be used to navigate the cursor around the 
buffer. If you happen to use a "weird" terminal setting and vim doesn't 
understand the arrow keys, use these instead.

This is just a small sampling of vim. Like Word, 90% of vi users only use 
10% of its features and functions*.

--Jeff

"I am not available for comment"


*86.7% of all statistics are made up.



More information about the Novalug mailing list