Thursday, October 30, 2008

find the matching bracket in emacs

Parenthesis balancing in EMACS

An unbalanced parenthesis is one of the most common sources of a programmer's grief. So emacs has a couple of useful features for guarding against them.

You may have noticed that when you are writing C++ code with emacs and type a closing parenthesis, bracket, or brace, the cursor does a little hop to the matching opening character and then returns to its working position. If there is a problem finding the match, emacs flashes the message ``Mismatched parentheses'' in the minibuffer. If the match is so far back in the code that it isn't visible, emacs flashes the context of the matching parenthesis in the minibuffer.

Parenthesis checking can also be done with the mouse. Double left click on any parenthesis, brace, or bracket. Emacs then shows the matching symbol and highlights the code between them.

Source for this information was this.

Friday, October 17, 2008

Minimize all open windows simultaneously in Linux

How do I simultaneously minimize all open windows in Linux ?

What is the Linux equivalent of WindowsKey+D in Linux ?


In Gnome its Ctrl+Atl+D.

Source is from this page :D

I would have found this out had I checked

System > Preferences > Personal > Keyboard Shortcuts

that was the path at least on Fedora Core 7 .

Monday, October 13, 2008

Emacs Auto-fill mode for multiline comments

Basically I wanted to write multiple lines of comments in .cpp files without having to manually type a double slash ( // ) in front of each comment. While googling for solutions I hit this page which says the following:

When Auto Fill mode is on, going past the fill column while typing a comment causes the comment to be continued...

So I start googling to find out how to enable the Auto-fill mode and in my search I hit this page which says:

When Auto Fill mode is turned off, lines continue to the right as you type them. Depending on how you set the value of truncate-lines, the words you type either disappear off the right side of the screen, or else are shown, in a rather ugly and unreadable manner, as a continuation line on the screen.

I like the Auto-fill mode :D

I am not too sure if I should turn Auto-fill mode on for all .cpp files ! Guess this post will have to wait.

Saturday, October 4, 2008

rename files with same first name but different extentions

The scenario is this. You have a folder/directory with the following files:
a.txt, a.ps, a.pdf
and you want to change the file names to
b.txt, b.ps, b.pdf
Here is how to do it.

for file in `ls a.*`
do
mv $file b.${file##*.}
done

basically the ${file##*.} extracts the extensions of the file. On the same note ${file%*.} will extract the first names of the files.

got it from this page :)