Linux Editors
Editors
There are many editors available for Linux, however the most common are briefly outlined below. Nano is arguably the most simple for the first time user, Vi and emacs are more powerful, while nedit is good for those used to a windows environment. Which to use is down to personal preference.
Below is a very brief guide to each, with some of the most common commands highlighted. As with most apps, copy and paste via the mouse (highlight and middle mouse button with putty or exceed for instance) are available as well as internal copy and paste commands.
Nano
nano (formerly pico) is probably the simplest standard editor and appears at first glance as most Windows text editors do - called with nano filename, if filename doesn't exist a blank page opens ready for composition, if filename does exist then the file is opened for editing. Unlike many console apps, nano can't be put to the background with CTRL Z. Start with nano -w filename to turn word wrap off
Save | CTRL + o |
Exit | CTRL + x (then confirm |
Cut line | CTRL + k (within nano only) |
Paste line | CTRL + u (within nano only) |
Find | CTRL + w (then enter search string |
Find again | CTRL + w |
Find line number | CTRL + w CTRL + t |
Next page | CTRL + v |
Previous page | CTRL + y |
Help | CTRL + g |
Nedit
nedit is a simple graphical editor, which can be customised and functionality extended using macros.
Vi
vi (vim) is a more powerful but more complicated tool, allowing for elegant mass editing of text. Vi can be started either with the traditional vi filename or when lessing a file, by pressing v (note exiting vi here will return to the less view). Vi has many commands allowing for all sorts of editing shortcuts, the most common presented below. Unlike Nano and Windows editors, a new vi session does not immediately allow you to write, instead you must invoke the insertion mode (i or a etc). Pressing ESC then exits the editing mode and returns you to reading mode, enabling you to save etc. Part of benefit of vi is the ability to incorporate sed commands into the editing, which is very useful, lots of instructions available through search engines.
gvim
is a gui version of vi (vi is "vi iMproved") which may be more intuitive for a beginner.
Save | :w |
Save and exit | :wq |
Exit | :q! |
Insert (before cursor) | i (ESC to exit) |
Append text (after cursor) | a (ESC to exit) |
Open new line below | o (ESC to exit) |
Delete line | dd |
Copy line | yy |
Delete word | dw |
Change word | cw |
Copy line | yy |
Paste | p |
Find | :/searchphrase |
Find again | / |
Next page | CTRL + f |
Previous page | CTRL + b |
Undo | u |
Click here for an vim reference card.
Emacs
Similar to vi, emacs is a more powerful editor. It allows users to create macros and fine grained customisations. The emacs short cut keys are the ones used for the BASH shell. There is a plethora of documentation and good books available on emacs, with support for the many programming languages, LaTeX and shell scripting. Below is a screen shot of emacs.
To edit a file in emacs, type emacs -nw filename.tex
- the table below lists the most common emacs functions.
Save | CTRL x + CTRL s |
Exit | CTRL x + CTRL c |
Load filename | CTRL x + CTRL f filename |
Cut line | CTRL k |
Paste line | CTRL y |
Find forward | CTRL s |
Find reverse | CTRL r |
Beginning of document | ESC < |
End of document | ESC > |
Page up | ESC v |
Page down | CTRL v |
Upper case word | ESC u |
Lower case word | ESC l |
Click here for an emacs reference card.