<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>SSH Help - Bash Resource Guide</title>
	<link>http://www.sshhelp.com</link>
	<description>ssh help, ssh resource, ssh guide</description>
	<pubDate>Sat, 02 Jun 2007 23:02:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>
	<language>en</language>
			<item>
		<title>VI  Cheat Sheet</title>
		<link>http://www.sshhelp.com/ssh/vi-cheat-sheet/</link>
		<comments>http://www.sshhelp.com/ssh/vi-cheat-sheet/#comments</comments>
		<pubDate>Sun, 13 May 2007 19:41:46 +0000</pubDate>
		<dc:creator>Brian Modansky</dc:creator>
		
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.sshhelp.com/ssh/vi-cheat-sheet/</guid>
		<description><![CDATA[The vi is a text editor. It is small, powerful, and standard on most UNIX systems. The vi often frustrates new users with a unique distinction between its two modes: Command Mode and Insert/Overtype Mode. This distinction, although difficult to become accustomed to for many users, provides great power and ability to the vi editor. [...]]]></description>
			<content:encoded><![CDATA[<p>The vi is a text editor. It is small, powerful, and standard on most UNIX systems. The vi often frustrates new users with a unique distinction between its two modes: Command Mode and Insert/Overtype Mode. This distinction, although difficult to become accustomed to for many users, provides great power and ability to the vi editor. Insert/Overtype Mode is designed for inserting text only. All text manipulations and cursor moving should be done from with in Command Mode. To know the vi editor well, is to love it. This page is not meant to replace the vi manual or vi man page. They are fine the way they are. This page is to provide a quick reference sheet for the vi editor and it&#8217;s most often used functions. Editors such as vim or vile are supersets (at least for the most part) of the vi editor, so this page should still prove useful. I hope even the most ardent vi lover can find something useful in this vi editor reference page.</p>
<p>Entering the vi<br />
prompt$ vi<br />
prompt$ vi file1 file2 &#8230;<br />
prompt$ vi -r file 	#Recover file from crash<br />
prompt$ vi +string file 	#Execute ex command &#8220;string&#8221;<br />
prompt$ vi @rcfile 	#Read commands from rcfile<br />
Insert/Overtype Mode</p>
<p>Insert/Overtype Mode is solely for entering text. To leave one of these two modes press the [ESC] key. if you wish to enter the ESC character or any other control character while in insert mode: type [CONTROL]-V and then the control sequence. The only difference between Insert Mode and Overtype Mode is that characters are placed in front of the text after the cursor in Insert Mode, where as existing characters are overwritten in Overtype Mode.<br />
Command Mode<br />
Entering Insert Mode<br />
a	append text, after the cursor<br />
i	insert text, before the cursor<br />
R	enter Overtype Mode<br />
A	append text, after end of line<br />
I	insert text, before first non-whitespace character<br />
o	open new line below cursor in Insert Mode<br />
O	open new line above cursor in Insert Mode<br />
vi Syntax</p>
<p>vi commands follow the general form:<br />
    n operator m object<br />
which means:<br />
    execute operator n times on m objects. If n and/or m are omitted, they default to 1.<br />
Operators which take objects are(if the operator is pressed twice then the object is the current line)<br />
    c	Change<br />
    d	Deletion<br />
    &#8220;cy	Yank, if &#8220;c is omitted, uses general buffer.<br />
    <	shift lines left by shiftwidth variable<br />
    >	shift lines right by shiftwidth variable<br />
    !cmd	filter trough cmd<br />
    #The operators <, >, and ! are line based so the set of objects is diminished greatly.<br />
Operators which do not take objects:<br />
    s	Substitute<br />
    x	Delete character<br />
    r	Replace character<br />
    ~	change case of character<br />
Objects (if given without an operator are interpreted as a cursor motion command):<br />
    w	forward until beginning of word<br />
    e	forward until end of word<br />
    b	backward until beginning of word<br />
    $	forward until end of line<br />
    ^	backward until first non-whitespace character<br />
    0	backward until first column of line<br />
    nG	line number n. (default: $, i.e. last line of file)<br />
    n|	column n of current line<br />
    /pat	forward until beginning of pat, search<br />
    ?pat	backward until beginning of pat, backward search<br />
    n	repeat last search<br />
    N	repeat last search/backward search, but in opposite direction<br />
    %	until match of parenthesis, brace, or bracket<br />
    tc	until next appearance of c on current line<br />
    Tc	backward until next appearance of c on current line<br />
    fc	until and including next appearance of c on current line<br />
    Fc	backward until and including next appearance of c on current line<br />
    ;	repeat last f, F, t, or T<br />
    ,	repeat last f, F, t, or T in reverse<br />
    }	forward until end of paragraph<br />
    {	backward until end of paragraph<br />
    )	forward until end of sentence<br />
    (	backward until end of sentence<br />
    ]]	forward until end of section<br />
    [[	backward until end of section<br />
    nH	n lines before first line on screen; n defaults to 0<br />
    nL	n lines before last line on screen; n defaults to 0<br />
    M	the middle line of the screen<br />
    j	down one line<br />
    k	up one line<br />
    h	left one character<br />
    l	right one character<br />
    [BS]	left one character, backspace usually equals ^H<br />
    [SPACE]	right one character<br />
    _	the entire current line<br />
    -	until first non-whitespace character on previous line<br />
    +	until first non-whitespace character on next line<br />
    [RETURN]	until first non-whitespace character on next line</p>
<p>Miscellaneous¹<br />
u	undo last change<br />
U	undo entire line<br />
&#8220;cp	put &#8220;c or general buffer after the cursor<br />
&#8220;cP	put &#8220;c or general buffer before the cursor<br />
mc	set mark with character c<br />
`c	goto mark c<br />
&#8216;c	goto beginning of line with mark c<br />
&#8220;	return to position before mark jump or search<br />
&#8221;	return to beginning of line before mark jump or search<br />
J	join two lines<br />
D	delete rest of line<br />
C	change rest of line<br />
Y	yank current line into general buffer<br />
&#038;	execute last ex-style substitution<br />
.	execute last modification<br />
!obj cmd	send object as stdin to command and replace with stdout<br />
[Ctrl]-G	print information about file<br />
: map x y	when character x is pressed, execute y<br />
: map! x y	map input mode character x to string y<br />
: ab x y	x is an abbreviation for y, changes are made on the fly<br />
: su	Suspend the current editor session<br />
: sh	run a shell<br />
ex Commands<br />
ex syntax</p>
<p>ex commands in the vi follow this general form:<br />
    : addr command<br />
which means:<br />
    Execute command on specific lines obtained from the address part of the general form. If address is omitted, current line is used. Keep in mind that the ex is a line based editor, so all actions are line based.<br />
addresses:<br />
    %	all lines in file<br />
    x,y	lines x to y<br />
    .	current line<br />
    n	line number: n<br />
    $	last line of file<br />
    x-n	n lines before line x<br />
    x+n	n lines after line x<br />
    /pat/	forward to line containing pat<br />
    ?pat?	backward to line containing pat<br />
Some commands are:<br />
    refer to ex manual page for more commands<br />
    s/pat/text/	substitute 1st match of pat with text<br />
    s/pat/text/g	substitute every match of pat with text<br />
    s/pat/text/n	substitute the nth occurrence of pat with text<br />
    ya c	yank into buffer c or the general buffer if c is omitted<br />
    g address cmd	execute cmd on all lines which satisfy address<br />
    >	shift right<br />
    <	shift left<br />
    d	delete line<br />
    ! UNIX-cmd	execute UNIX-cmd on line<br />
    m address	move lines to address</p>
<p>The vi environment variables</p>
<p>set<br />
    You can customize your environment with this command by typing set var=value, this will set the specified var to value for a scalar variable. For boolean variables, use set var to set and set novar to unset. You can see which variables are set by just typing the set by its self. You can see a list of all variables by typing set all. Some environment variables are specific to the ex editor and some are specific to the vi editor. I have included both. </p>
<p>(I am missing some variables, please contact me with additions.)<br />
boolean variables:<br />
autoindent(ai)	begin editing next line at same level of indent-ion as this one.<br />
autowrite(aw)	write current buffer before leaving<br />
exrc(ex)	tells vi/ex if it should read the .exrc file in the current directory(this can be a security risk).<br />
errorbells	editor sends a beep to the terminal when an incorrect<br />
flash	inverse the screen on an error instead of producing a bell<br />
ignorecase(ic)	ignore case of characters in searches.<br />
lisp	enter lisp mode<br />
list	place a $ at the end of each line and a ^I on each tab.<br />
magic	allow ., [, and * to be interpreted as special characters in RE's.<br />
modelines	execute the first and last 5 lines of the file if of the form: ex:command: or vi:command:<br />
number(nu)	number lines in left margin<br />
showmatch(sm)	when closing a paren., brace or bracket; move the visual cursor to opening item to check scope<br />
showmode(smd)	show type of insert mode<br />
wrapscan(ws)	when searching and at bottom of file, continue searching from the top<br />
scalar variables:<br />
directory	the location of the temporary directory used by vi<br />
paragraphs(para)	macros to signify the beginning of a paragraph<br />
report	vi will notify you if you change more lines than the value of report<br />
sections(sect)	macros to signify the beginning of a section<br />
shell	The shell to use when executing the command :sh or :!<br />
shiftwidth(sw)	number of spaces to to insert on a shift operation<br />
showmatch(sm)	show the match of ) and } when typed<br />
tabstop	the length, in characters, of a tabstop<br />
term	holds the name of the terminal type being used<br />
wrapmargin(wm)	split lines at the column which is equal to the value of wrapmargin<br />
File Saving and Loading<br />
: wq	write file and quit<br />
: w	write file<br />
: w file	write to specified file<br />
: w!	overwrite existing file<br />
: e file	edit new file<br />
: r file	put contents of file<br />
: q	quit the editor<br />
: q!	force quit the editor, do not save changes<br />
: x	quit the editor, save file if it was modified<br />
ZZ	quit the editor, save file if it was modified<br />
: n	start editing next file in list<br />
: rew	rewind file list, start editing 1st file on argument list again<br />
Q	quit vi and enter ex<br />
: pre	Preserve file.<br />
: rec file	recover file<br />
Examples²<br />
j	move cursor down<br />
k	move cursor up<br />
h or [BS]	move cursor left<br />
l or [SPACE]	move cursor right<br />
+ or [RETURN]	first non-whitespace character on next line<br />
cw	change word<br />
dd or d_	delete line<br />
yy or y_	yank current line into the general buffer<br />
"ayj	yank current line and one below into buffer a<br />
yfc	yank until next occurrence of c on current line into the general buffer<br />
3dl or d3l	delete next 3 characters<br />
4c( or 2c2( or c4(	change next 4 sentences<br />
>%	while on a brace, paren., or bracket; shift right until closing brace, etc.<br />
:%!sort or :1,$!sort	sort current file<br />
:5,10s/foo/bar/2	change the second occurrence of foo with bar on lines 5-10<br />
:map g 1G	map g to really run 1G<br />
3J	Join next 2 lines to current one<br />
3,9m$	move lines 3 through 9 to the end of the file<br />
ab w/o without	when w/o is typed change to without<br />
:?foo?,/bar/d	delete from the reverse match of foo until the next match of bar<br />
:g/{/,/}/<	shift all lines between, and including, a &#8220;{&#8221; and a &#8220;}&#8221; left<br />
:$-4,$d	delete last five lines of buffer<br />
:%s/^\(.*\) \(.*\)$/\2 \1/	swap everything before and after the first space<br />
d&#8221;	delete from current position to line of last jump</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sshhelp.com/ssh/vi-cheat-sheet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SSH Help Coming Soon!</title>
		<link>http://www.sshhelp.com/ssh/ssh-help-coming-soon/</link>
		<comments>http://www.sshhelp.com/ssh/ssh-help-coming-soon/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<dc:creator>Brian Modansky</dc:creator>
		
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[SSH Help Coming Soon!
]]></description>
			<content:encoded><![CDATA[<p>SSH Help Coming Soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sshhelp.com/ssh/ssh-help-coming-soon/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
