<?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>TechBuddy &#187; Unix/Linux</title>
	<atom:link href="http://techbuddy.in/category/unixlinux/feed/" rel="self" type="application/rss+xml" />
	<link>http://techbuddy.in</link>
	<description>Technology blog</description>
	<lastBuildDate>Sun, 25 Jul 2010 06:30:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Solved : rcmd socket permission denied</title>
		<link>http://techbuddy.in/2009/12/30/solved-rcmd-socket-permission-denied/</link>
		<comments>http://techbuddy.in/2009/12/30/solved-rcmd-socket-permission-denied/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 07:11:04 +0000</pubDate>
		<dc:creator>Techbuddy</dc:creator>
				<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[permission denied]]></category>
		<category><![CDATA[rcmd socket permission denied]]></category>
		<category><![CDATA[rsh]]></category>

		<guid isPermaLink="false">http://techbuddy.in/?p=408</guid>
		<description><![CDATA[Recently I was stuck with one problem in linux configuration. I wanted to rsh to one machine A from other machine B but I was continuously getting “rcmd socket permission denied” error.]]></description>
			<content:encoded><![CDATA[<p>Recently I was stuck with one problem in linux configuration. I wanted to rsh to one machine A from other machine B but I was continuously getting “rcmd socket permission denied” error.<br />
Command was : rsh bbb.bbb.bbb.bbb –l username<br />
aaa.aaa.aaa.aaa is IP address of local machine<br />
bbb.bbb.bbb.bbb is IP address of remote machine<br />
This are the steps I performed to solve the problem after lots of googling.<br />
1)	Open the .rhosts file on remote machine B for the ‘username’  and add this line.<br />
aaa.aaa.aaa.aaa username<br />
+ root<br />
2)	Open the /etc/hosts.equiv file on remote machine B and add this line.<br />
aaa.aaa.aaa.aaa username<br />
+ root<br />
3)	Open /etc/pam.d/rsh file and added “promiscuous” to pam_rhosts_auth.so<br />
auth       required     pam_rhosts_auth.so promiscuous<br />
4)	Add rsh in to /etc/securetty file<br />
5)	Permissions and ownership of .rhosts file is changed to eligible one.<br />
6)	Run ‘which rsh’ to find out which rsh is used. Suppose it /usr/bin/rsh.  Then change permission of /usr/bin/rsh by ‘chmod 4755 /usr/bin/rsh’<br />
After performing these steps I was able to run rsh command on remote machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://techbuddy.in/2009/12/30/solved-rcmd-socket-permission-denied/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Can not find name for user ID XXX in unix</title>
		<link>http://techbuddy.in/2009/11/03/can-not-find-name-for-user-id-xxx-in-unix/</link>
		<comments>http://techbuddy.in/2009/11/03/can-not-find-name-for-user-id-xxx-in-unix/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 05:54:58 +0000</pubDate>
		<dc:creator>Techbuddy</dc:creator>
				<category><![CDATA[Unix/Linux]]></category>

		<guid isPermaLink="false">http://techbuddy.in/2009/11/03/can-not-find-name-for-user-id-xxx-in-unix/</guid>
		<description><![CDATA[I installed Sendmail mail daemon in my linux machine. It took some time to configure the mail server. I was able to send mails to users using (as root),
	mail –s “hi” username
	data
	.
I also can check the mail of the users using 
mail –u username
But when I login to machine as that user I can not see any mails, I also noticed that id commands doesn’t return the use name, but also shows the id of the user. 
>id
uid=3880 gid=124(e2m) groups=124(e2m),200(cvsusers)
I also checked that while login to system using username other ...]]></description>
			<content:encoded><![CDATA[<p>I installed Sendmail mail daemon in my linux machine. It took some time to configure the mail server. I was able to send mails to users using (as root),<br />
	mail –s “hi” username<br />
	data<br />
	.<br />
I also can check the mail of the users using </p>
<p>mail –u username</p>
<p>But when I login to machine as that user I can not see any mails, I also noticed that id commands doesn’t return the use name, but also shows the id of the user. </p>
<p>>id<br />
uid=3880 gid=124(e2m) groups=124(e2m),200(cvsusers)</p>
<p>I also checked that while login to system using username other then root. I get error message like,</p>
<p>	id: cannot find name for user ID 3880</p>
<p>After searching a lot in internet I found many solutions but they all were regarding ldap and all thing. I do not use any ldap in my machine. After a lot of search I found a very easy solution. Permission of my /etc/passwd file was set to -rw&#8212;&#8212;- instead of -rw-r&#8211;r&#8211;.<br />
I changed the permission and my problem is solved.</p>
<p>chmod 644 /etc/passwd</p>
<p>I thought this to share with other guys who might face this problem in future..</p>
]]></content:encoded>
			<wfw:commentRss>http://techbuddy.in/2009/11/03/can-not-find-name-for-user-id-xxx-in-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create scrollable input form with textbox popup in TCL/TK</title>
		<link>http://techbuddy.in/2009/08/28/how-to-create-scrollable-input-form-with-textbox-popup-in-tcltk/</link>
		<comments>http://techbuddy.in/2009/08/28/how-to-create-scrollable-input-form-with-textbox-popup-in-tcltk/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 16:47:39 +0000</pubDate>
		<dc:creator>Techbuddy</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[passing value from toplevel]]></category>
		<category><![CDATA[popup]]></category>
		<category><![CDATA[popup textbox]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[scrollable form]]></category>
		<category><![CDATA[TCL TK]]></category>

		<guid isPermaLink="false">http://techbuddy.in/?p=118</guid>
		<description><![CDATA[TCL/TK is the very convient script language to create GUI on X-windows platform. Basically it wraps the call of X-Motif and allows user to create GUI very quickly without worry about X-motif functions..
Thought TCL is  quite easy to use, it misses some useful functions. One of that is scrolling. Recently I was stuck-ed in similar problem. My requirement was to create a scrollable page with possibility to enter data by user.
Tcl/Tk only allows to attach scroll bar with  Entry, Listbox and canvas widgets. If I use canvas then ...]]></description>
			<content:encoded><![CDATA[<p>TCL/TK is the very convient script language to create GUI on X-windows platform. Basically it wraps the call of X-Motif and allows user to create GUI very quickly without worry about X-motif functions..</p>
<p>Thought TCL is  quite easy to use, it misses some useful functions. One of that is scrolling. Recently I was stuck-ed in similar problem. My requirement was to create a scrollable page with possibility to enter data by user.</p>
<p>Tcl/Tk only allows to attach scroll bar with  Entry, Listbox and canvas widgets. If I use canvas then I can not create textbox(entry) on canvas that is scrollable with the canvas. Entry and label widgets created on canvas are not scrollable.</p>
<p>I took another approach. I created text on the canvas and bind the mouse click of text to a procedure. This procedure opens the toplevel widget on the current window with one entry widget and OK/Cancel buttons. Now on OK click data entered in the text box is passed to parent window and the text in the parent window is updated. This is not straightforward way but that’s I could do with TCL.</p>
<p>I have created a simple example of my original problem, which is described below.</p>
<p>Below program creates a scrollable canvas and put 3 texts on it. Clicking on it will open text box to enter the value. Note that I have not put any validation on it as its just a demo program.. Edit it according to your need. I took TCL TK practical programming book as reference</p>
<p># PROGRAM START</p>
<p>#!/usr/bin/wishx<br />
frame .f</p>
<p>canvas .f.c -width 300 -height 100 -scrollregion {0 0 500 500} -xscrollcommand {.f.sx set} \<br />
-yscrollcommand {.f.sy set}<br />
scrollbar .f.sx -orient horizontal -command {.f.c xview}<br />
scrollbar .f.sy -orient vertical -command {.f.c yview}<br />
pack .f.sx -side bottom -anchor s -fill x<br />
pack .f.sy -side right -anchor e -fill y<br />
pack .f.c -anchor nw -fill both -expand y<br />
pack .f -fill both -expand y</p>
<p>set ROW_NUMBER 1</p>
<p>proc Popup { FieldValue FieldTag } {</p>
<p>global Value</p>
<p>set Value(result) $FieldValue<br />
set f [toplevel .prompt -borderwidth 10]<br />
message $f.msg -text &#8220;Enter New value &#8221;<br />
entry $f.entry -textvariable Value(result)<br />
set b [frame $f.buttons -bd 10]<br />
pack $f.msg $f.entry $f.buttons -side top -fill x</p>
<p>bind $f.entry &lt;Return&gt; {set Value(ok) 1}<br />
bind $f.entry &lt;Control-c&gt; {set Value(ok) 0}<br />
button $b.ok -text OK -command {set Value(ok) 1}<br />
button $b.cancel -text Cancel -command {set Value(ok) 0}</p>
<p>pack $b.ok<br />
pack  $b.cancel</p>
<p>focus $f.entry<br />
tkwait variable Value(ok)<br />
destroy $f<br />
if {$Value(ok)} {<br />
.f.c itemconfigure $FieldTag -text $Value(result)<br />
set {$FieldName} $Value(result)<br />
} else {<br />
return {}<br />
}<br />
}</p>
<p>set NameValue &#8220;No Value&#8221;<br />
.f.c create text 10 [expr $ROW_NUMBER *25] -anchor nw -text &#8220;Enter Name :&#8221;<br />
.f.c create text 200 [expr $ROW_NUMBER *25] -anchor nw -text $NameValue -tag NameValueTag</p>
<p>.f.c bind NameValueTag &lt;Button-1&gt; &#8220;Popup {$NameValue} NameValueTag&#8221;</p>
<p>set ROW_NUMBER [expr $ROW_NUMBER + 1]</p>
<p>set LastNameValue &#8220;No Value&#8221;<br />
.f.c create text 10 [expr $ROW_NUMBER *25] -anchor nw -text &#8220;Enter Last Name :&#8221;<br />
.f.c create text 200 [expr $ROW_NUMBER *25] -anchor nw -text $LastNameValue -tag LastNameValueTag</p>
<p>.f.c bind LastNameValueTag &lt;Button-1&gt; &#8220;Popup {$LastNameValue} LastNameValueTag&#8221;</p>
<p>set ROW_NUMBER [expr $ROW_NUMBER + 1]</p>
<p>set TelNoValue &#8220;No Value&#8221;<br />
.f.c create text 10 [expr $ROW_NUMBER *25] -anchor nw -text &#8220;Enter Telephone No :&#8221;<br />
.f.c create text 200 [expr $ROW_NUMBER *25] -anchor nw -text $TelNoValue -tag TelNoValueTag</p>
<p>.f.c bind TelNoValueTag &lt;Button-1&gt; &#8220;Popup {$TelNoValue} TelNoValueTag&#8221;</p>
<p>wm title . &#8220;Popup Demo&#8221;</p>
<p># PROGRAM END</p>
]]></content:encoded>
			<wfw:commentRss>http://techbuddy.in/2009/08/28/how-to-create-scrollable-input-form-with-textbox-popup-in-tcltk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Very useful VI commands handbook</title>
		<link>http://techbuddy.in/2009/07/27/very-useful-vi-command-handbook/</link>
		<comments>http://techbuddy.in/2009/07/27/very-useful-vi-command-handbook/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 17:57:34 +0000</pubDate>
		<dc:creator>Techbuddy</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[useful vi editor command]]></category>
		<category><![CDATA[vi editor]]></category>
		<category><![CDATA[vi editor handbook]]></category>

		<guid isPermaLink="false">http://techbuddy.in/?p=30</guid>
		<description><![CDATA[Useful Vi editor commands.
If you are using Unix then you must have used the VI editor for text edition. Vi Editor is the best editor in my view. If you have practiced enough and mastered the frequent command then you can understand its power.
I have summarized the basic commands and some useful command one should know to speed up VI editor use. I will not go in to details of how commands work. 
There are mainly three modes of commands in VI editor, Insert mode, Command mode and colon mode. ...]]></description>
			<content:encoded><![CDATA[<p><strong>Useful Vi editor commands.</strong></p>
<p>If you are using Unix then you must have used the VI editor for text edition. Vi Editor is the best editor in my view. If you have practiced enough and mastered the frequent command then you can understand its power.</p>
<p>I have summarized the basic commands and some useful command one should know to speed up VI editor use. I will not go in to details of how commands work. </p>
<p>There are mainly three modes of commands in VI editor, Insert mode, Command mode and colon mode. Generally insert mode can be bring by pressing i, a, o etc. And Esc is pressed to go back to Command mode. Colon mode can be started by pressing colon “:” in command mode.</p>
<p><strong>Cursor movement: </strong><br />
h : to move cursor 1 position left<br />
j :  to move cursor 1 line down<br />
k : to move cursor 1 line up<br />
l : to move cursor 1 position right<br />
G: to move cursor to end of the file (nG can be used to go to nth line in the file)<br />
gg : to move cursor to start of the file<br />
$ : to move cursor to end of the line<br />
^ :to move cursor to beginning  of the line.<br />
b : to move cursor to beginning of the current/previous word.<br />
w : to move cursor to beginning of the next word.<br />
e : to move cursor to end of the next word.<br />
f : f is used to find the character. It is used with the character to be found. E.g. fn will find the first n character from the current position.<br />
F : F is same as f but searches character on the reverse direction.</p>
<p>^f : to scroll full page down<br />
^d : to scroll half page down<br />
^u : : to scroll half page up<br />
^b : : to scroll full page up</p>
<p>Can be used with numbers as 10h to move cursor 10 position left. </p>
<p><strong>Deletion of text:</strong><br />
x (dl): to delete the current character under cursor.<br />
dw : to delete the current word.<br />
dd : to delete the current line.<br />
d$ (D) : to delete the text from current position to end of line.<br />
d^ : to delete the text from start of line to current position.<br />
dG : to delete the content below the current position. </p>
<p>Can be used with numbers as 10dd to delete 10 lines.</p>
<p><strong>Replacing the charater:</strong><br />
r : to replace the current character under cursor. Current character is replaced by the immediate typed character.</p>
<p><strong>Copying (yanking):</strong><br />
yy : to copy the current line<br />
yw : to copy the current word</p>
<p>$, ^, G can be used in combination just as used above with d.<br />
Can be used with numbers as 10yy to copy 10 lines.</p>
<p>In fact, When we use d commands for deletion, it also copies the deleted contents.</p>
<p><strong>Paste the copied content: </strong></p>
<p>p : is used to paste the content copied by y command or deleted by d command at current cursor position.</p>
<p>Commands to get in Insert mode: </p>
<p>i : to start editing from before current cursor position<br />
a : to start editing from after current cursor position<br />
o : A new line is added below the current line and cursor is now placed to start of new line.<br />
O : A new line is added above the current line and cursor is now placed to start of new line.<br />
s : deletes the character at current cursor position and edition is started from there.</p>
<p><strong>Searching the pattern:</strong></p>
<p>Mainly / and ? are used for pattern matching in vi editor. To search the string or word , press / or ? in command mode and type the pattern to be searched and press enter.<br />
Both work in the same way except the direction of the search. / searches the pattern in forward direction and ? searches the pattern in reverse direction. When command is executed all found occurrence of pattern can be traverse by n and N. In case of / was used to search the pattern then n is used to move to next occurrence and N is used to move to previous occurrence.  For ? n and N works in opposite manner.</p>
<p>Wild card characters can be used to enhance the search, e.g.</p>
<p>/ABC$ can be used to search string ABC at the end of line.</p>
<p>/^ABC can be used to search string ABC at the start of line.</p>
<p>* can be used to search the current word. This can be very handy to use. </p>
<p><strong>Indenting the code:</strong></p>
<p><< : is used to shift the current line to left by one shift width<br />
>> : is used to shift the current line to right by one shift width</p>
<p>shift width can be specifying by :set sw=4 or it can be set in .vimrc file (will cover later). </p>
<p><strong>Parenthesis matching: </strong><br />
% : if the cursor is on the parenthesis ( (,{,[ ) then it will jump to matching parenthesis.</p>
<p><strong>Visual mode:</strong><br />
Some times there is a case when you want to copy large number of lines and you do not know the number of lines, Visual mode can rescue you. Press v to enter the visual mode. Move the cursor whatever text you want to select. Selected text is highlighted.  Press y to copy the selected text and paste it wherever you want it.</p>
<p><strong>Buffers in vi editor: </strong><br />
Vi editor uses buffer to store different copied content (like clipboard in windows). There are two types of buffers, temporary buffer and lettered buffer. By default by temporary buffer is used by vi editor so each time you copy buffer is overwritten.<br />
Lettered buffer are used in case you want to paste the more then one content frequently.</p>
<p>Lettered buffer are denoted by “ and followed by alphabet. E.g. “a means buffer a. Total 26 different buffers can be used (a-z).</p>
<p>“ayy : to copy a line to buffer a<br />
“ap : to paste the content of buffer a<br />
“a3yy : to copy 3 lines to buffer a</p>
<p>Different combination of copy paste can be used with buffers also.<br />
If same buffer is used to store the content then previous value is overwritten. Capital letters can be used if you want to amend the content, e.g.</p>
<p>“Ayy : Amends to buffer a.</p>
<p><strong>Copy till marked position:</strong></p>
<p>This is almost same way of copying text as visual mode. In this we first mark the position from where we want to copy and then move to the position till we want to copy. </p>
<p>ma : marks current position as a<br />
y’a : copy from current position to marked position a</p>
<p><strong>Colon mode commands:</strong></p>
<p>:q : to quit the file<br />
:q! : to forcefully quit the file (changes will be lost)<br />
:w : write the file<br />
:wq : write and quit the file<br />
:r filename : reads the specified file.<br />
:h : to display help of vi editor (specify the help file to read by :h helpfilename)<br />
:n : no move to next file if more then one files are open.<br />
:s : to search and replace by pattern matching (substitution)<br />
   syntax for substitution is : :ranges/pattern/pattern/options<br />
Range : this can be provided as comma separated line numbers e.g. :10,20s/ptn1/ptn2/g. This  will search from line 10 to 20 and replace ptn1 with ptn2</p>
<p>% can be provided as range if you want to search in entire file.</p>
<p>Pattern : Pattern is basically a string. Variety of regular expressions can be used to specify the pattern.</p>
<p>Options: I don’t know much options to use here but mainly I use g and c/</p>
<p>g : to replace all occurrences of the pattern in a line. If it is not specified then only first occurrence is replaced.<br />
c : to confirm the change.</p>
<p>Some example of substitute command,</p>
<p>:10,20s/aaa/bbb   replaces first occurrences of aaa from line 10 to 20 with bbb.<br />
:10,20s/aaa/bbb/g   replaces all occurrences of aaa from line 10 to 20 with bbb.<br />
:10,20s/aaa/bbb/gc   replaces all occurrences of aaa from line 10 to 20 with bbb after confirmation of the change.<br />
 :%s/aaa/bbb/g   replaces all occurrences of aaa with bbb in entire file.<br />
:%/^aaa/bbb/g   replaces all occurrences of aaa which are in start of line with bbb.<br />
:%/$/bbb/g   replaces end of each line with bbb.</p>
<p><strong>Options from colon mode</strong><br />
:set all Display all options<br />
:set Display current settings of options<br />
:set nooption Unset option<br />
:set ai Set Auto Indentation during text entry<br />
:set ic Set Ignore Case during searches<br />
:set nu Show line Numbers<br />
:set sm Show Matching ( or { when ) or } is entered<br />
:set wm=10 Set Wrap Margin 10 spaces from right edge of screen</p>
<p>This all options are only valid for the current session of vi, they are lost as soon as you exit the editor. To set your desired options by default, .vimrc file is used.</p>
<p>Create .vimrc  file in your home directory and specify all options you want here. Now each time you open the vi editor your favourite options are set.</p>
<p><strong>Abbreviations:</strong></p>
<p>This is a cool feature provided by vi editor. You can provide an abbreviation for frequently used word and make you like easier. Take an example that I have to enter my full name many times in my files so I can create an short abbreviation for it and use it everywhere. Vi editor will automatically replace it with my full name.</p>
<p>Syntax is<br />
:ab fn Nikunj Lodhia</p>
<p>Now in insert mode when I type fn and then press space or enter then fn is changed to Nikunj Lodhia (I use this feature a lot).<br />
Frequently used abbreviations can be set in .vimrc file.</p>
<p>:una is used to remove the abbreviations e.g. :una fn </p>
<p><strong>Auto Complete:</strong></p>
<p>Yes, vim has also auto complete feature. You have to be in insert mode to use this feature.</p>
<p>^n : This will auto complete the current word with matching word. If more then one matching words are found then press ^n again to move to next match.<br />
^p : it works same but in reverse direction.</p>
<p>Suppose in your file you have word myVariable. In insert mode type myV and press ^n, vi will change it to myVariable. (this is also a cool feature to use)</p>
<p><strong>Repeating the insert:</strong></p>
<p>If you press CTRL-A, the editor inserts the text you typed the last time you<br />
were in Insert mode.<br />
   Assume, for example, that you have a file that begins with the following:</p>
<p>        "file.h"<br />
        /* Main program begins */</p>
<p>You edit this file by inserting "#include " at the beginning of the first<br />
line:</p>
<p>        #include "file.h"<br />
        /* Main program begins */</p>
<p>You go down to the beginning of the next line using the commands "j^".  You<br />
now start to insert a new "#include" line.  So you type:</p>
<p>        i CTRL-A</p>
<p>The result is as follows:</p>
<p>        #include "file.h"<br />
        #include /* Main program begins */</p>
<p>The "#include " was inserted because CTRL-A inserts the text of the previous<br />
insert.  Now you type  "main.h"<Enter>  to finish the line:</p>
<p>        #include "file.h"<br />
        #include "main.h"<br />
        /* Main program begins */</p>
<p>The CTRL-@ command does a CTRL-A and then exits Insert mode.  That's a quick<br />
way of doing exactly the same insertion again.</p>
<p><strong>completing file names </strong> </p>
<p>Let's take CTRL-X CTRL-F as an example.  This will find file names.  It scans<br />
the current directory for files and displays each one that matches the word in<br />
front of the cursor.<br />
   Suppose, for example, that you have the following files in the current<br />
directory:</p>
<p>        main.c  sub_count.c  sub_done.c  sub_exit.c</p>
<p>Now enter Insert mode and start typing:</p>
<p>        The exit code is in the file sub</p>
<p>At this point, you enter the command CTRL-X CTRL-F.  Vim now completes the<br />
current word "sub" by looking at the files in the current directory.  The<br />
first match is sub_count.c.  This is not the one you want, so you match the<br />
next file by typing CTRL-N.  This match is sub_done.c.  Typing CTRL-N again<br />
takes you to sub_exit.c.  The results:</p>
<p>        The exit code is in the file sub_exit.c</p>
<p>If the file name starts with / (Unix) or C:\ (MS-Windows) you can find all<br />
files in the file system.  For example, type "/u" and CTRL-X CTRL-F.  This<br />
will match "/usr" (this is on Unix):<br />
        the file is found in /usr/</p>
<p>If you now press CTRL-N you go back to "/u".  Instead, to accept the "/usr/"<br />
and go one directory level deeper, use CTRL-X CTRL-F again:</p>
<p>        the file is found in /usr/X11R6/</p>
<p>The results depend on what is found in your file system, of course.  The<br />
matches are sorted alphabetically.</p>
<p><strong> Set max characters in one line </strong></p>
<p>Vi editor also provides a way to set maximum characters in one line. In many project there is a requirement that not more that 80 characters should be in one line. It can be done by,</p>
<p>	:set textwidth=xx </p>
<p>Here xx is number of characters. When you insert characters more then specified in<br />
textwidth, Vi editor automatically creates a new line for it.</p>
<p><strong> Alignment of text </strong></p>
<p>Yes you are right alignment of text is available in Vi editor also. This could be least known feature to users hence many users don’t know about it. It will align the text in center, right or left side.</p>
<p>	:{range}center [width]<br />
	:{range}right [width]<br />
	:{range}left [width]</p>
<p>Here range is standard range used in vi editor commands like `s`. Width is optional argument which specifies the width in which text will be aligned. 	If it is not specified then textwidth is used instead.</p>
<p><strong> Justifying text </strong></p>
<p>Vim has no built-in way of justifying text.  However, there is a neat macro<br />
package that does the job.  To use this package, execute the following<br />
command:</p>
<p>        :runtime macros/justify.vim</p>
<p>This Vim script file defines a new visual command &#8220;_j&#8221;. To justify a block of<br />
text, highlight the text in Visual mode and then execute &#8220;_j&#8221;.</p>
<p><strong> Making change in many files </strong></p>
<p>Suppose you have a variable called &#8220;x_cnt&#8221; and you want to change it to<br />
&#8220;x_counter&#8221;.  This variable is used in several of your C files.  You need to<br />
change it in all files.  This is how you do it.<br />
   Put all the relevant files in the argument list:</p>
<p>        :args *.c</p>
<p>This finds all C files and edits the first one.  Now you can perform a<br />
substitution command on all these files:</p>
<p>        :argdo %s/\<x_cnt\>/x_counter/ge | update</p>
<p>The &#8220;:argdo&#8221; command takes an argument that is another command.  That command<br />
will be executed on all files in the argument list.<br />
   The &#8220;%s&#8221; substitute command that follows works on all lines.  It finds the<br />
word &#8220;x_cnt&#8221; with &#8220;\<x_cnt\>&#8220;.  The &#8220;\<" and "\>&#8221; are used to match the whole<br />
word only, and not &#8220;px_cnt&#8221; or &#8220;x_cnt2&#8243;.<br />
   The flags for the substitute command include &#8220;g&#8221; to replace all occurrences<br />
of &#8220;x_cnt&#8221; in the same line.  The &#8220;e&#8221; flag is used to avoid an error message<br />
when &#8220;x_cnt&#8221; does not appear in the file.  Otherwise &#8220;:argdo&#8221; would abort on<br />
the first file where &#8220;x_cnt&#8221; was not found.<br />
   The &#8220;|&#8221; separates two commands.  The following &#8220;update&#8221; command writes the<br />
file only if it was changed.  If no &#8220;x_cnt&#8221; was changed to &#8220;x_counter&#8221; nothing<br />
happens.</p>
<p>There is also the &#8220;:windo&#8221; command, which executes its argument in all<br />
windows.  And &#8220;:bufdo&#8221; executes its argument on all buffers.  Be careful with<br />
this, because you might have more files in the buffer list than you think.<br />
Check this with the &#8220;:buffers&#8221; command (or &#8220;:ls&#8221;).</p>
<p><strong>Maping the key:</strong></p>
<p>:map keys sequences</p>
<p>e.g. map ^N iNikunj</p>
<p>now when I press ^N then I will be in insert mode and Nikunj will be added before the cursor</p>
<p><strong>Miscellaneous commands:</strong></p>
<p>^a : if the cursor is on a number then it will be incremented by 1.<br />
^x : if the cursor is on a number then it will be decremented by 1.<br />
gd : move to the declaration of the variable under cursor. (should be locally declared)<br />
. : repeat last command<br />
u : undo last change<br />
J : join next line to end of current line<br />
~: switch the case of character<br />
^g : show current file name and status<br />
:! : to run shell commands e.g. :!ls</p>
<p>These are only summary of the commands. I will improve the details of commands as soon as I get time. Hope this page is helpful to you. </p>
]]></content:encoded>
			<wfw:commentRss>http://techbuddy.in/2009/07/27/very-useful-vi-command-handbook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
