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: 24098 | 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: 81812 | 15 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: 25916 | 2 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: 38745 | 3 Comments »

Some Trick for VIM

September 4th, 2006 liewsheng

When I converting a e-code to SystemVerilog syntax, I realize that I don’t like the format created by the script. The script creating port which group them under a line, but I like them if they separte in different line for different port. So I need to replace some special character with a new line. [...]

Posted in vi, vim | Hits: 12639 | 2 Comments »

split windows view in vim

August 21st, 2006 mysurface

Sometimes you would likes to have split view. You can compare the codes at the same time on the same screen. So when switching tabs or buffer is not convenience to you, you can consider to open more split windows. To open another windows, and lead you to current directory for file selection, you can [...]

Posted in Text Manipulation, vi, vim | Hits: 35581 | No Comments »

open multiple files in tabs, vim 7 can do that.

August 16th, 2006 mysurface

Remember last time when I open multiple files using vim, it will be loaded and store at the back buffer, in order to bring it to front, you need to first save your current file with :w then :bn for next :bp for previous. But seems vim 7 support tabs, I would like to open [...]

Posted in alias, Text Manipulation, vi, vim | Hits: 52208 | 12 Comments »

key mapping of vim 7

August 15th, 2006 mysurface

vim is a very popular editor which it have more than one mode, and it is flexible to allow you for mapping your key to the features. The common map keywork is :map, which the key is map and functional when you are in normal, visual mode. To make a key to edit a file [...]

Posted in Text Manipulation, vi, vim | Hits: 13538 | 4 Comments »

tabs in vim 7

August 15th, 2006 mysurface

This was amazing when I get to know that vim can do tab. Okay to do that, it is easy, what you need is to do a key binding. Create a file .vimrc into your home folder, and paste the lines bellow into it. :map <F4>:tabprevious<cr> :map <F3>:tabnext<cr> :map <C-t>:tabnew .<cr> :imap <F4>:tabprevious<cr>i :imap <F3>:tabnext<cr>i [...]

Posted in ln, Text Manipulation, vi, vim, which | Hits: 29934 | 2 Comments »

searching man page inside vi editor

August 4th, 2006 mysurface

This is a tips provided by my friend durian. In order to search for man page while you are viewing either script or source code using vi editor, you can search for man page without quiting vi editor. put your cursor over the keyword which you want to look up, and press shift-K Let say [...]

Posted in Text Manipulation, vi, vim | Hits: 22408 | 3 Comments »