Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 18: Editing C, C++, and Java Files

Previous HourNext Hour

Sections in this Hour:

 

Exercises

1. Similar to the example given, you have if'd out a block of code and the cursor is at the end of the new block, so the code looks like this:


if(foo) {
     line1();
     line2();
     }

The cursor is at the end of the last line. You need to reindent the code in the if statement. This hour explained how to do this without moving the cursor. Come up with a way to do it with the least number of keystrokes without causing Emacs to reindent the entire function or buffer.

2. If you have a program with several preprocessor conditionals, write a hook for hideif that defines the correct values for your preprocessor symbols for two different platforms. Now load your source file and switch between these two virtual platforms.

Sams Teach Yourself Emacs in 24 Hours

ContentsIndex

Hour 18: Editing C, C++, and Java Files

Previous HourNext Hour

Sections in this Hour: