EMACS
Emacs is the program editor that we use, it is simple, different than
Windows
Software, but efficient!
How to use
At the top of the window you have the menu, at the bottom you
have
the command line.
-
Files that you open in emacs are stored in buffers, you can
open
more files, to switch to another file than the currently displayed, use
Control
+ left mouse click to get a list of the files or use menu item Buffers.
-
File manipulation: under menu item Files
-
open file: Open File and type in the path of the file at the
command
line
-
tip: if your directory or filename is incomplete, press TAB to
complete
the name. If there are multiple possibilities and you press TAB
again, you get a list of all possibilities.
-
use the shortcut: Control-x-f (keep the Control key down and
press
x first and then f)
-
new file: the same as Open File, type the name of the new file
and
emacs creates it for you.
-
save file: Save Buffer or Control-x-s
-
close file: Kill Current Buffer
-
use Split Window to visualise multiple files (very handy!)
-
when your file has changed outside emacs: choose Revert Buffer
to
upload the changements (this menu item is only activated when the file
has changed outside of emacs)
-
Menu item Tools: use Print -> Print Buffer to print your
file at
the default printer
-
Edit
-
Cut: select a text and press Control-w
-
Copy: just select the text, you don't have to press
anything, emacs
always remembers the last selected text
-
Paste: Control-y or use the middle mouse
button, as
explained
here.
-
Search
-
Search or Control-S: type the word you are looking
for in
the command line
-
press Control-S again to find the next
-
use Query Replace of the Search menu item to replace a
word
by another
-
you'll have to press y or n each time to say if you
want
the word being replaced or not
-
More
-
Esc: to escape from a command in the command line (press 3
times)
-
Control-e to go the end of the line
-
Press Escape to exit commands (lot's of times it is necessary
to
do it multiple times to get back in normal mode)
Learn to use emacs, learn the shortcuts and have programming fun!!
C++ in emacs
The power of emacs is that it has special features for c or c++ files.
When you open a .c, .h or .cc file, emacs recognises it as a c or c++
file,
you get a coloured file and a c or c++ menu item:
-
use Comment Out Region to put the selected text in comments
-
use the Tab key to indent your program automatically!!
Documentation: Help => Manuals => Browse Manuals with Info
=> Gnu
Libraries: Libc
To compile:
-
press the F3, you get "make -k" in the command line, complete
it
with the rule of your makefile (the makefile of the directory of the
current
selected file is used!!) and press ENTER
- if F3 doesn't work, start it via menu Tools -> Compile
- you can type any linux command here
-
use the Up & Down arrows to reuse old commands (the history)
-
press
Control-c-c on an compilation error to go automatically to
the line of the error in the code!