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: 66912 | 3 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: 37709 | 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: 24559 | 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: 9736 | 2 Comments »

turn off laptop LCD monitor

November 12th, 2006 mysurface

In order to save power, I often turn off my LCD monitor when I away from keyboard for long. Bare in mind, blank screen is not consider turn off the monitor, because it still uses backlight. To do that, first you need to make sure you have ACPI enabled in your kernel. cat /proc/acpi/info If [...]

Posted in cat, Misc, X11, xset | Hits: 80409 | 29 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: 19707 | 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: 22889 | 6 Comments »

Redirect output to multiple processes

November 8th, 2006 toydi

Since tee can read the standard input, and write to multiple files, we may leverage this feature so that it writes to multiple processes (instead of files). tee >(process1) >(process2) >(process3) | process4 >( ) (see process substitution) pretends itself as a write-only file. Everything you write into it, will be passed to the command [...]

Posted in Common, grep, process substitution, tee | Hits: 134702 | 34 Comments »

Compare two directory listings

November 8th, 2006 toydi

Given two directories: ~/dir-new/ and ~/dir/, $ ls ~/dir-new/ file-01.txt file-02.txt file-new.txt $ ls ~/dir/ file-01.txt file-02.txt file-old.txt To compare them: comm

Posted in comm, process substitution, Text Manipulation | Hits: 96722 | 14 Comments »

Matching Whole Word in Grep

November 7th, 2006 liewsheng

Is “grep” capable to match a whole word? The answer of cause is yes!! grep -w “keyword” filename this will only display the line with matching word. Using the file contents in previous example, if this command enter: grep -w “ates” filename you will get: ates, 953645 Related Posts“Number” Manipulation in Grep”grep” will able to [...]

Posted in grep, Text Manipulation | Hits: 56424 | 1 Comment »