<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LAMPDocs &#187; Programming</title>
	<atom:link href="http://www.lampdocs.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lampdocs.com</link>
	<description>Documenting the Open Source</description>
	<lastBuildDate>Sat, 03 Dec 2011 15:09:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>vi Command list for Command Line Editing</title>
		<link>http://www.lampdocs.com/programming/vi-command-list-for-command-line-editing/</link>
		<comments>http://www.lampdocs.com/programming/vi-command-list-for-command-line-editing/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 05:56:44 +0000</pubDate>
		<dc:creator>Vladimir Usenco</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[save file vi]]></category>
		<category><![CDATA[vi delete line]]></category>
		<category><![CDATA[vi delete to the end of file]]></category>
		<category><![CDATA[vi exit withot saving]]></category>
		<category><![CDATA[vi insert character]]></category>
		<category><![CDATA[vi search for expression]]></category>
		<category><![CDATA[vi tutorial]]></category>

		<guid isPermaLink="false">http://www.lampdocs.com/?p=959</guid>
		<description><![CDATA[vi commands with explanation, everything related to vi commands. 


Related posts:<ol><li><a href='http://www.lampdocs.com/uncategorized/searching-files-in-linux/' rel='bookmark' title='Searching files in Linux'>Searching files in Linux</a></li>
<li><a href='http://www.lampdocs.com/linux-distros/insert-v1-3-9b/' rel='bookmark' title='INSERT v1.3.9b'>INSERT v1.3.9b</a></li>
<li><a href='http://www.lampdocs.com/other-recipes/all-you-need-to-view-pdf-documents-in-linux/' rel='bookmark' title='All you need to view PDF documents in Linux'>All you need to view PDF documents in Linux</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>As you already know, Linux has some things that require command line even for user tasks. Most of them are connected with file modification. There are some ways to alter files from command line, and one of the most effective seems to be vi. It is a powerful editor that comes with lots of functions and if you know its hotkeys, it will save you lots of time. Some people say that it cannot be compared even with Windows text editors. So let me show you several things that will make your interaction with vi more pleasant.</p>
<p>We&#8217;ll start with cursor control, as it&#8217;s the first need when you open a file.</p>
<p><strong>h </strong> Left<br />
<strong>j </strong> Down<br />
<strong>k </strong> Up<br />
<strong>l </strong>(or<strong> spacebar</strong>)    Right</p>
<p>Of course, you&#8217;re welcome to use keyboard arrows if you like them so much. There are some more complicated manipulations, so let me show them. These commands will help you to navigate between your file text in a smart way.</p>
<p><strong>w</strong> Forward one word<br />
<strong>b </strong> Back one word<br />
<strong>e</strong> End of word<br />
<strong>( </strong> Beginning of current sentence<br />
<strong>) </strong> Beginning of next sentence<br />
<strong>{ </strong> Beginning of current paragraph<br />
<strong>} </strong> Beginning of next paragraph<br />
<strong>[[</strong> Beginning of current section<br />
<strong>]]</strong> Beginning of next section<br />
<strong>0 </strong> Start of current line<br />
<strong>$ </strong> End of current line<br />
<strong>^ </strong> First non-white character of current line<br />
<strong>+</strong> or <strong>Return</strong> (<strong>Enter</strong>)    First character of next line<br />
<strong>- </strong> First character of previous line<br />
<strong>n | </strong> character n of current line</p>
<p>If your file takes some screens, there are some commands for screen movements.</p>
<p><strong>H</strong> Top line of current screen<br />
<strong>M</strong> Middle line of current screen<br />
<strong>L </strong> Last line of current screen<br />
<strong>nH</strong> n lines after top line of current screen<br />
<strong>nL </strong> n lines before last line of current screen<br />
<strong>Ctrl-F </strong> Forward one screen<br />
<strong>Ctrl-B</strong> Back one screen<br />
<strong>Ctrl-D </strong> Down half a screen<br />
<strong>Ctrl-U </strong> Up half a screen<br />
<strong>Ctrl-E </strong> Display another line at bottom of screen<br />
<strong>Ctrl-Y </strong> Display another line at top of screen<br />
<strong>z Return</strong> (<strong>Enter</strong>)  Redraw screen with cursor at top<br />
<strong>z . </strong> Redraw screen with cursor in middle<br />
<strong>z &#8211; </strong> Redraw screen with cursor at bottom<br />
<strong>Ctrl-L </strong> Redraw screen without re-positioning<br />
<strong>Ctrl-R </strong> Redraw screen without re-positioning</p>
<p>Of course, there are some commands related to search and moving between line numbers.<br />
<strong>/text</strong> Search for text (forwards)<br />
/    Repeat forward search (Just like F3 in Microsoft Windows)<br />
<strong>?text </strong> Search for text (backwards)<br />
<strong>? </strong> Repeat previous search backwards<br />
<strong>n</strong> Repeat previous search<br />
<strong>N</strong> Repeat previous search, but it opposite direction<br />
/text/+n    Go to line n after text<br />
<strong>?text?-n </strong> Go to line n before text<br />
<strong>%</strong> Find match of current parenthesis, brace, or bracket (very useful for programmers).<br />
<strong>Ctrl-G </strong> Display line number of cursor<br />
<strong>nG</strong> Move cursor to line number n<br />
<strong>:n </strong> Move cursor to line number n<br />
<strong>G </strong> Move to last line in file</p>
<p>As you can see, there are lots of ways to navigate within a file. Let&#8217;s start with wile editing commands, they aren&#8217;t less interesting.</p>
<p><strong>A</strong> Append to end of current line<br />
<strong>i </strong> Insert before cursor<br />
<strong>I </strong> Insert at beginning of line<br />
<strong>o </strong> Open line above cursor<br />
<strong>O </strong> Open line below cursor<br />
<strong>ESC</strong> End of insert mode<br />
<strong>Ctrl-I</strong> Insert a tab<br />
<strong>Ctrl-T</strong> Move to next tab position<br />
<strong>Backspace</strong> Move back one character<br />
<strong>Ctrl-U</strong> Delete current line<br />
<strong>Ctrl-V </strong> Quote next character<br />
<strong>Ctrl-W</strong> Move back one word<br />
<strong>cw </strong> Change word<br />
<strong>cc </strong> Change line<br />
<strong>C </strong> Change from current position to end of line<br />
<strong>dd </strong> Delete current line<br />
<strong>ndd </strong> Delete n lines<br />
<strong>D</strong> Delete remainer of line<br />
<strong>dw </strong> Delete word<br />
<strong>d} </strong> Delete rest of paragraph<br />
<strong>d^ </strong> Delete back to start of line<br />
<strong>c/pat </strong> Delete up to first occurance of pattern<br />
<strong>dn</strong> Delete up to next occurance of pattern<br />
<strong>dfa</strong> Delete up to and including a on current line<br />
<strong>dta </strong> Delete up to, but not including, a on current line<br />
<strong>dL </strong> Delete up to last line on screen<br />
<strong>dG </strong> Delete to end of file<br />
<strong>J </strong> Join two lines<br />
<strong>p </strong> Insert buffer after cursor<br />
<strong>P </strong> Insert buffer before cursor<br />
<strong>rx </strong> Replace character with x<br />
<strong>Rtext </strong> Replace text beginning at cursor<br />
<strong>s </strong> Substitute character<br />
<strong>ns </strong> Substitute n characters<br />
<strong>S </strong> Substitute entire line<br />
<strong>u </strong> Undo last change</p>
<p>And we finally come to file manipulation commands as we will need to save (or not) our changes.</p>
<p><strong>:w </strong> Write file<br />
<strong>:w! </strong> Write file (ignoring warnings, force writing)<br />
<strong>:w! file </strong> Overwrite file (ignoring warnings)<br />
<strong>:wq </strong> Write file and quit<br />
<strong>:q </strong> Quit<br />
<strong>:q!</strong> Quit (even if changes not saved)<br />
<strong>:w file </strong> Write file as file, leaving original untouched<br />
<strong>ZZ </strong> Quit, only writing file if changed<br />
<strong> <img src='http://www.lampdocs.com/wp-includes/images/smilies/icon_mad.gif' alt="icon mad vi Command list for Command Line Editing" class='wp-smiley' title="vi Command list for Command Line Editing" />  </strong> Quit, only writing file if changed<br />
<strong>:n1,n2w file </strong> Write lines n1 to n2 to file<br />
<strong>:n1,n2w &gt;&gt; file </strong> Append lines n1 to n2 to file<br />
<strong>:e file2    Edit file2</strong> (current file becomes alternate file)<br />
<strong>:e! </strong> Reload file from disk (revert to previous saved version)<br />
<strong>:e# </strong> Edit alternate file<br />
<strong>% </strong> Display current filename<br />
<strong>#</strong> Display alternate filename<br />
<strong>:n </strong> Edit next file<br />
<strong>:n! </strong> Edit next file (ignoring warnings)<br />
<strong>:n files </strong> Specify new list of files<br />
<strong>:r file </strong> Insert file after cursor<br />
<strong>:r !command</strong> Run command, and insert output after current line</p>
<p>As you can see, the number of vi commands is really huge. If you get acquainted to this editor, you won&#8217;t even try anything else, the professional programmers say. If you need vi to edit files (e.g. crontab modification), you will find all the necessary commands above.</p>
<p>Have a good time with vi! <img src='http://www.lampdocs.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile vi Command list for Command Line Editing" class='wp-smiley' title="vi Command list for Command Line Editing" /> </p>


<p>Related posts:<ol><li><a href='http://www.lampdocs.com/uncategorized/searching-files-in-linux/' rel='bookmark' title='Searching files in Linux'>Searching files in Linux</a></li>
<li><a href='http://www.lampdocs.com/linux-distros/insert-v1-3-9b/' rel='bookmark' title='INSERT v1.3.9b'>INSERT v1.3.9b</a></li>
<li><a href='http://www.lampdocs.com/other-recipes/all-you-need-to-view-pdf-documents-in-linux/' rel='bookmark' title='All you need to view PDF documents in Linux'>All you need to view PDF documents in Linux</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.lampdocs.com/programming/vi-command-list-for-command-line-editing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

