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: 24546 | 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: 36494 | 3 Comments »

beware of non-ascii characters

October 13th, 2006 mysurface

When I copy source code from an ebook in pdf format and paste into vim, and I try to compile it fails. The reason it fails is because it contains non-ascii character, for my case it uses UTF-8 encorded characters. You can check out the non-ascii or hidden characters by doing this: cat -v mycode.c [...]

Posted in cat, Misc, sed, Text Manipulation | Hits: 45205 | 5 Comments »

Substitute a Keyword In a File

October 9th, 2006 liewsheng

Sometime I need to replace a keyword with another, I can’t just open a file and substitute 1 by 1. It is faster to using a single command line. There have more than 2 ways to do it, but I prefer this 2 command: perl and sed. To substitute a word ‘abc’ to ‘def’ in [...]

Posted in perl, sed, Text Manipulation | Hits: 40561 | 5 Comments »