search next or backward and goto line tips for vim

December 16th, 2006 mysurface

To search in vim is very simple, even a noob vim user know that, /keyword To search for next? simply follow by pressing n for next keyword match point and search backward with shift+n or N. Wanna highlight the keyword and search for next keyword match point? Place your cursor at the desire word, and [...]

Posted in Text Manipulation, vi, vim | Hits: 34607 | 1 Comment »

vim with ctags

December 10th, 2006 mysurface

If you are c/c++ programmer and vim user, maybe know ctags. Most of the time, source code are distributed to many folders and each of them consist of numbers of .cc/.c and .h. Sometimes to search the definition of a function, class, enums etc by using “/” is inefficient. ctags allow fast jumping to function [...]

Posted in ctags, Developer, ln, vi, vim | Hits: 157055 | 24 Comments »

regex in vim to clear the trailing character

December 6th, 2006 mysurface

Sometimes, the file created at windows may tag alone the trailing character at the end of every line, where user press enter. It may shows as ^M. It is very irritating! to clear it off is very easy in vim. :%s/\s*\r*$// %s is global search, change effect on every lines, \s is space \s* is [...]

Posted in Text Manipulation, vi, vim | Hits: 23562 | 1 Comment »

compare files and edit simultaneously with vimdiff

November 24th, 2006 mysurface

Refers to How to create patch file using patch and diff, you can actually read the diff file to compare the difference between the files. But what if you wanna compare and edit simultaneously? Given 2 different files at your hand, you can do that with vimdiff. Let say I wanna compare this two files [...]

Posted in Developer, vi, vim, vimdiff | Hits: 74931 | 11 Comments »

VIM Tip 1: Align

November 19th, 2006 aizatto

I like having my code aligned properly, for example, the following is not cool. The assignment operator is not aligned properly :(. LIONS = 1 TIGERS = 2 BEARS = 3 This is what I want, it adds a certain zen to the code. LIONS = 1 TIGERS = 2 BEARS = 3 Yes you [...]

Posted in Misc, vim | Hits: 38850 | 8 Comments »

Running vim command while opening files

November 19th, 2006 mysurface

Refers back to Open file to edit with vim at desire line, here is another short tips of vim. You can execute the vim command, while opening files with vim with option -c. While I wanna replace a string from a huge file, first I need to check whether I can do it with sed [...]

Posted in sed, Text Manipulation, vi, vim | Hits: 25238 | 2 Comments »

VIM Tip 0

November 16th, 2006 aizatto

Because of popular demand, I will be starting a series on VIM tips, for people interested in learning VIM. VIM is a great text editor, and I use it for everything, including slicing bread. The best thing is that it brings me the speed I need for programming. Since I’ll be thinking of what to [...]

Posted in vim | Hits: 10076 | 2 Comments »

String Substitution in VIM

November 9th, 2006 liewsheng

VIM is a powerful text editor, it have a lot of feature like tag, syntax highlighting…and many more. Here I only show some useful vim command. To start the VIM editor: vim <filename> <filename> is a option. If no <filename> specific, VIM will open a empty buffer for you. After you have edit, If you [...]

Posted in vim | Hits: 20195 | 5 Comments »

Open file to edit with vim at desire line

November 9th, 2006

You know that you can open a file with the desire line the curser will stop at for example, when you get some error message say the code have error at line 3 of file text1, you can use the + to specify you curser starting point. vim text1 +3 Related Postsvim tips, goto lineIf [...]

Posted in Text Manipulation, vim | Hits: 23695 | 6 Comments »

search and replace

November 1st, 2006 mysurface

This is a very common needs, to search a keyword and replace it with another. Give you a simple example, when I want to perform a ubuntu distribution upgrade from dapper to edgy, I need to edit the file /etc/apt/sources.list. To do that i can either uses vim, or simply uses sed. The vim way. [...]

Posted in Misc, sed, sudo, Text Manipulation, vi, vim | Hits: 37690 | 3 Comments »