Friday, July 30, 2010

Replacing ^M character at end of line using VI editor ( ^H, ^G and so on..)

Some time these characters are placed when you convert file from DOS format to Linux format. These characters can be viewed only with Vi editor or either typing "cat -v" command for that file in command prompt. These characters are called control characters.

These characters can be deleted using ":%s/.$//g" command from VI prompt.
To replace character use it like ":%s/.$/replace/g" Press Ctrl Q+M, and this will character will come up. In some other format it can be typed using ctrl V+M.

But before doing all this do ":set ff=dos", to change file format to DOS.

At last a simple trick for Gvim on Windows XP:
:%s/\r/\r/g
This replaces unix carriage return by windows CRLF.

following is the list of Ctrl characters:

Hex Name
0x00 NUL
0x01 SOH, Control-A
0x02 STX, Control-B
0x03 ETX, Control-C
0x04 EOT, Control-D
0x05 ENQ, Control-E
0x06 ACK, Control-F
0x07 BEL, Control-G
0x08 BS, backspace, Control-H
0x09 HT, tab, Control-I
0x0a LF, line feed, newline, Control-J
0x0b VT, Control-K
0x0c FF, form feed, NP, Control-L
0x0d CR, carriage return, Control-M
0x0e SO, Control-N
0x0f SI, Control-O
0x10 DLE, Control-P
0x11 DC1, XON, Control-Q
0x12 DC2, Control-R
0x13 DC3, XOFF, Control-S
0x14 DC4, Control-T
0x15 NAK, Control-U
0x16 SYN, Control-V
0x17 ETB, Control-W
0x18 CAN, Control-X
0x19 EM, Control-Y
0x1a SUB, Control-Z

Thursday, July 15, 2010

Searching and replacing in VIM

Vim has a command ":s(substitute)" for search and replace text. It searches for text and replace the text.

:%s/abc/xyz/g 
Find each occurrence of 'abc', and replace it with 'xyz'.


:%s/\<abc\>/xyz/gc 
Change only whole words exactly matching 'abc' to 'xyz'; ask for confirmation.

:%s/abc/xyz/gci
Change each 'abc' (case insensitive) to 'xyz'; ask for confirmation.

:%s/abc/xyz/gcI 
Change each 'abc' (case sensitive) to 'xyz'; ask for confirmation.

:s/abc/xyz/g
Replaces in current line only
 :%s/abc/xyz/g
Replaces in all lines
:4,8s/abc/xyz/g
Replaces all abc by xyz in lines between 4 & 8


So ":%s" is equivalent to ":1,$s"

Modifiers:
g: GLobal
c: confirmation
i: case insensitive
I: Case sensitive

Reference: VIM Wiki

Saturday, July 10, 2010

Get more detailed Info on your computer

Hi,
I know you want to know details about your computer's directx componets and their drivers are installed, and what they are using. this tool lets you diagnose problems and change your system settings to best. So to check more detailed info on your computer, which is not even available on My computer->Properties section, Follow the steps:
1. Open RUN Prompt.
2. type dxdiag and enter
3. Make sure you have original version version of XP because it will propmt for that.
4. Once it opens up it will show information on : System, DirectsX Files, Music, Display, Sound, Input devices etc..
5. To save this info click on "Save all information" and select the location. Information will be saved in form of .txt file.

Creating folder wothout any name

you will be wondering, how to create a folder without any name.. Have you ever tried it?? If no then try it now..

Here is the solution for this..
1. Create a folder in any directory.
2. Right click on folder and select "Rename folder" or press F2
3. Now press Alt and Type 255(ALT+255) or ALT+0160
4. Now it's done.