Saturday, May 9, 2009

text editors in linux both cli and gui

INTRODUCTION

The first text editors were line editors oriented on typewriter style terminals and they did not provide a window or screen-oriented display. They usually had very short commands (to minimize typing) that reproduced the current line. Among them were a command to print a selected section(s) of the file on the typewriter (or printer) in case of necessity. An "edit cursor", an imaginary insertion point, could be moved by special commands that operated with line numbers of specific text strings (context). Later, the context strings were extended to regular expressions. To see the changes, the file needed to be printed on the printer. These "line-based text editors" were considered revolutionary improvements over keypunch machines. In case typewriter-based terminals were not available, they were adapted to keypunch equipment. In this case the user needed to punch the commands into the separate deck of cards and feed them into the computer in order to edit the file.
When computer terminals with video screens became available, screen-based text editors became common. One of the earliest "full screen" editors was O26 - which was written for the operator console of the CDC 6000 series machines in 1967. Another early full screen editor is vi. Written in the 1970s, vi is still a standard editor for Unix and Linux operating systems. The productivity of editing using full-screen editors (compared to the line-based editors) motivated many of the early purchases of video terminals. Some text editors are small and simple, while others offer a broad and complex range of functionality. For example, Unix and Unix-like operating systems have the vi editor (or a variant), but many also include the Emacs editor. Microsoft Windows systems come with the very simple Notepad, though many people—especially programmers—prefer to use one of many other Windows text editors with more features. Under Apple Macintosh's classic Mac OS there was the native SimpleText, which was replaced by TextEdit. Some editors, such as WordStar, have dual operating modes allowing them to be either a text editor or a word processor.
Text editors geared for professional computer users place no limit on the size of the file being opened. In particular, they start quickly even when editing large files, and are capable of editing files that are too large to fit the computer's main memory. Simpler text editors often just read files into an array in RAM. On larger files this is a slow process, and very large files often do not fit.
The ability to read and write very large files is needed by many professional computer users. For example, system administrators may need to read long log files. Programmers may need to change large source code files, or examine unusually large texts, such as an entire dictionary placed in a single file






VI Editor
The VI editor is a screen-based editor used by many Unix users. The VI editor has powerful features to aid programmers, but many beginning users avoid using VI because the different features overwhelm them. This tutorial is written to help beginning users get accustomed to using the VI editor, but also contains sections relevant to regular users of VI as well. Examples are provided, and the best way to learn is to try these examples, and think of your
.
Starting the VI Editor
The VI editor lets a user create new files or edit existing files. The command to start the VI editor is vi, followed by the filename. For example to edit a file called temporary, you would type vi temporary and then return. You can start VI without a filename, but when you want to save your work, you will have to tell VI which filename to save it into later.
When you start VI for the first time, you will see a screen filled with tildes (A tilde looks like this: ~) on the left side of the screen. Any blank lines beyond the end of the file are shown this way. At the bottom of your screen, the filename should be shown, if you specified an existing file, and the size of the file will be shown as well, like this:
"filename" 21 lines, 385 characters
If the file you specified does not exist, then it will tell you that it is a new file, like this:
"newfile" [New file]
If you started VI without a filename, the bottom line of the screen will just be blank when VI starts. If the screen does not show you these expected results, your terminal type may be set wrong. Just type :q and return to get out of VI, and fix your terminal type. If you don't know how, ask a lab monitor.
Getting Out of VI
Now that you know how to get into VI, it would be a good idea to know how to get out of it. The VI editor has two modes and in order to get out of VI, you have to be in command mode. Hit the key labeled "Escape" or "Esc" (If your terminal does not have such a key, then try ^[, or control-[.) to get into command mode. If you were already in the command mode when you hit "Escape", don't worry. It might beep, but you will still be in the command mode.
The command to quit out of VI is :q. Once in command mode, type colon, and 'q', followed by return. If your file has been modified in any way, the editor will warn you of this, and not let you quit. To ignore this message, the command to quit out of VI without saving is :q!. This lets you exit VI without saving any of the changes.
Of course, normally in an editor, you would want to save the changes you have made. The command to save the contents of the editor is :w. You can combine the above command with the quit command, or :wq. You can specify a different file name to save to by specifying the name after the :w. For example, if you wanted to save the file you were working as another filename called filename2, you would type: w filename2 and return.
Another way to save your changes and exit out of VI is the ZZ command. When in command mode, type ZZ and it will do the equivalent of :wq. If any changes were made to the file, it will be saved. This is the easiest way to leave the editor, with only two keystrokes.
The Two Modes of VI
The first thing most users learn about the VI editor is that it has two modes: command and insert. The command mode allows the entry of commands to manipulate text. These commands are usually one or two characters long, and can be entered with few keystrokes. The insert mode puts anything typed on the keyboard into the current file.
VI starts out in command mode. There are several commands that put the VI editor into insert mode. The most commonly used commands to get into insert mode are a and i. These two commands are described below. Once you are in insert mode, you get out of it by hitting the escape key. If your terminal does not have an escape key, ^[ should work (control-[). You can hit escape two times in a row and VI would definitely be in command mode. Hitting escape while you are already in command mode doesn't take the editor out of command mode. It may beep to tell you that you are already in that mode.
How to Type Commands in Command Mode
The command mode commands are normally in this format: (Optional arguments are given in the brackets)
[count] command [where]
Most commands are one character long, including those which use control characters. The commands described in this section are those which are used most commonly the VI editor.
The count is entered as a number beginning with any character from 1 to 9. For example, the x command deletes a character under the cursor. If you type 23x while in command mode, it will delete 23 characters.
Some commands use an optional where parameter, where you can specify how many lines or how much of the document the command affects, the where parameter can also be any command that moves the cursor.
Some Simple VI Commands
Here is a simple set of commands to get a beginning VI user started. There are many other convenient commands, which will be discussed in later sections.
a
enter insert mode, the characters typed in will be inserted after the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times.
h
move the cursor to the left one character position.
i
enter insert mode, the characters typed in will be inserted before the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times.
j
move the cursor down one line.
k
move the cursor up one line.
l
move the cursor to the right one character position.
r
replace one character under the cursor. Specify count to replace a number of characters
u
undo the last change to the file. Typing u again will re-do the change.
x
delete character under the cursor. Count specifies how many characters to delete. The characters will be deleted after the cursor.
Cutting and Yanking
The command commonly used command for cutting is d. This command deletes text from the file. The command is preceded by an optional count and followed by a movement specification. If you double the command by typing dd, it deletes the current line. Here are some combinations of these:
d^
deletes from current cursor position to the beginning of the line.
d$
deletes from current cursor position to the end of the line.
dw
deletes from current cursor position to the end of the word.
3dd
deletes three lines from current cursor position downwards.
There is also the y command which operates similarly to the d command which take text from the file without deleting the text.
Pasting
The commands to paste are p and P. The only differ in the position relative to the cursor where they paste. p pastes the specified or general buffer after the cursor position, while P pastes the specified or general buffer before the cursor position. Specifying count before the paste command pastes text the specified number of times.
Indenting Your Code and Checking
The VI editor has features to help programmers format their code neatly. There is a variable that to set up the indentation for each level of nesting in code. In order to set it up, see the customization section of this tutorial. For example, the command to set the shift width to 4 characters is :set sw=4.
The following commands indent your lines or remove the indentation, and can be specified with count:
<<
Shifts the current line to the left by one shift width.
>>
Shifts the current line to the right by one shift width.
The VI editor also has a helpful feature which checks your source code for any hanging parentheses or braces. The % command will look for the left parenthesis or brace corresponding to a particular right parenthesis or brace and vice versa. Place the cursor onto a parenthesis or brace and type % to move the cursor to the corresponding parenthesis or brace. This is useful to check for unclosed parentheses or braces. If a parenthesis or brace exists without a matching parenthesis or brace, VI will beep at you to indicate that no matching symbol was found.
Word and Character Searching
The VI editor has two kinds of searches: string and character. For a string search, the / and ? commands are used. When you start these commands, the command just typed will be shown on the bottom line, where you type the particular string to look for. These two commands differ only in the direction where the search takes place. The / command searches forwards (downwards) in the file, while the ? command searches backwards (upwards) in the file. The n and N commands repeat the previous search command in the same or opposite direction, respectively. Some characters have special meanings to VI, so they must be preceded by a backslash (\) to be included as part of the search expression.
Emacs Editor

Emacs is another editor available in UNIX. Like vi, emacs is a screen editor. Unlike vi, emacs is not an insertion mode editor, meaning that any character typed in emacs is automatically inserted into the file, unless it includes a command prefix.
Commands in emacs are either control characters (hold down the key while typing another character) or are prefixed by one of a set of reserved characters: or -X. The key can be typed by itself (because it really is a character) and then followed by another character; the key must be held down while the next character is being typed. The conventions for describing these characters (since it takes too long to type out the whole thing) are ESC means and C- means .
One other distinction between emacs and vi is that emacs allows you to edit several files at once. The window for emacs can be divided into several windows, each of which contains a view into a buffer. Each buffer typically corresponds to a different file. Many of the commands listed below are for reading files into new buffers and moving between buffers.
To use emacs on a file, type
emacs filename
If the file named filename exists, then the first screen's worth of the file is displayed; if it doesn't exist, a help message is displayed.
The easiest way to learn emacs is to start it up and go through the on-line tutorial. To access the on-line tutorial, type
ESC help-with-tutorial
immediately after you have started emacs. The tutorial directs you further in learning the basic commands. One notational point you should know is that the tutorial uses M- to mean ESC.








* C-h help-command: first character in lots of useful help commands
* C-h t help-with-tutorial: command to run the tutorial
C-h i information: describes most of the emacs commands in man style pages
C-h k describe-key: tells you what a particular key stroke does
* C-h a command-apropos: prompts for a string and
then searches for all emacs commands that contains that string
ESC ? also does command-apropos
* C-h ? help-for-help: describes how to use the help facilities

To give you a head start, the following table lists the basic commands you need to know to use emacs to edit a file. An asterisk (* or star) to the left of a command indicate it is one to learn immediately.
________________________________________
Help Commands
File Reading and Writing Commands
* C-x C-f find-file: first prompts for a filename and
then loads that file into a editor buffer of the same name
* C-x C-s save-buffer: saves the buffer into the associated filename
C-x C-w write-named-file: prompts for a new filename and writes the buffer into it

Cursor/Screen Movement Commands
Depending on the terminal, some of the cursor movement can be handled by the arrow keys.
* C-a move cursor to (at) beginning-of-line
C-e move cursor to end-of-line
* C-f move cursor forward one character
* C-b move cursor backward one character
* C-n move cursor to next line
* C-p move cursor to previous line
C-v scroll file forward by one screenful
ESC v scroll file backward by one screenful
* ESC < go to beginning-of-buffer
* ESC > go to end-of-buffer
ESC f move cursor forward one word
ESC b move cursor backward one word

Copy and Delete Commands
C-d delete-char: delete character under cursor
ESC d delete-word: delete from cursor to end of word immediately ahead of the cursor
* C-k kill-line: delete the rest of the current line
* C-@ set-mark-command: mark is used to indicate the beginning of an area of text to be yanked
* C-w kill-region: delete the area of text between the mark and the current cursor position
* C-y yank: insert at current cursor location whatever was most recently deleted
ESC w copy-region-as-kill: copy area between mark and cursor into kill-buffer
so that it can be yanked into someplace else

Search Commands
* C-s isearch-forward: prompts for text string and
then searches from the current cursor position forwards in the buffer
C-r isearch-backward: like isearch-forward,
but searches from the current cursor position to end of buffer for text string
ESC % query-replace: prompts for a search string and
a string with which to replace the search string

Window and Buffer Commands
C-x 0 zero-window: deletes current window
C-x 2 double-window: splits current window into two parts,
allowing you to edit at two different locations in the same file
or permitting you to view two different files at the same time
C-x b switch-to-buffer: display a different buffer on the screen
C-x o other-window: move the cursor to the other window
(assuming that you have two windows/buffers open at once
* C-x C-b list-buffers: lists those buffers currently loaded into emacs

Exiting Emacs, Fixing Mistakes and Other Important Stuff
* C-x C-c save-buffers-kill-emacs: when you are finished editing,
to save the edited but unsaved buffers
and to return you to the UNIX prompt
* C-g keyboard-quit: if while typing a command you make a mistake and want to stop,
this aborts a command in progress
C-u universal-argument: if you want to do a command several times,
type this command
followed by a number (for the number of times)
followed by the command you wish repeated
* C-x u undo: undoes the last command typed, in case you made a mistake
* ESC x execute-extended-command: prompts for the name of an emacs command;
allows you to execute a command
if you know roughly what it is called
but cannot remember the key strokes for it

________________________________________

Joe's Own Editor

JOE is a full featured terminal-based screen editor which is distributed under the GNU General Public License (GPL). JOE has been around since 1988 and comes standard with many Linux distributions.
JOE is being maintained by its original author Joseph Allen, plus all of the people who send bug reports, feature suggestions and patches to the project web site. JOE is hosted by SourceForge.net and its source code is controlled under CVS. Over the last few years there has been about one major new release a year, usually in the April-May timeframe.
JOE is a blending of MicroPro's venerable microcomputer word processor WordStar and Richard Stallman's famous LISP based text editor GNU-EMACS (but it does not use code from either program): most of the basic editing keys are the same as in WordStar as is the overall feel of the editor. JOE also has some of the key bindings and many of the powerful features of EMACS.
JOE is written in C and its only dependency is libc. This makes JOE very easy to build (just "configure" and "make install"), making it feasible to include on small systems and recovery disks. The compiled binary is about 300K in x86. Note that JOE can use either the termcap or terminfo terminal capabilities databases (or a built-in termcap entry for ANSI terminals). The choice is controlled by a "configure" option. If terminfo is used, a library is required to access the database (on some systems this library is ncurses, but JOE does not use curses to control the terminal- it has its own code for this).
Much of the look and feel of JOE is determined by its simple configuration file "joerc". Several variants of the editor are installed by default in addition to "joe": "jmacs" (emulate GNU-EMACS), "jstar" emulate WordStar, "jpico" emulate the Pine mailer editor PICO and "rjoe"- a restricted version of JOE which allows the used to only edit the file given on the command line. JOE is linked to several names. The name which is used to invoke the editor with "rc" tacked on the end gives the name of configuration file to use. It is thus easy for you to make your own variant if you want. Also you can customize the editor by copying the system "joerc" file to your home directory.
Here is a basic screen shot of JOE running in a Cygwin console:

Here is a screen shot showing several windows- the first has some example double-wide characters, the second is the same buffer as the first, but in hex-dump view mode, the third is a shell window and the fourth shows a selected rectangular block of numbers and their sum:

JOE has the following features:
• Multi-file search and replace- file list is either given on command line or by a UNIX command (grep/find) run from within JOE.
• Mouse support, including wheel (works best when using xterm). The mouse can resize windows, scroll windows, select and paste text, and select menu entries.
• Context display on status line: allows you to see name of function cursor is in.
• UTF-8 support, optional auto-detect of UTF-8 files.
• Syntax highlighting for more than 40 languages.
• Hexadecimal edit mode. Use JOE as a disk editor: joe -overwrite -hex /dev/hda1,0,512 (edit first sector of /dev/hda1).
• Non-destructive editing of binary files even when handling MS-DOS or UNIX line endings.
• Swap file allows editing files larger than memory.
• Context sensitive on-line help.
• Bash-like TAB completion and history for all prompts, or jump into the completion menu and use it to traverse the file system.
• Complete word in edit buffer by hitting ESC Enter (uses other words in buffer for dictionary).
• EMACS-compatible file locks and file modification checking.
• Shell windows.
• Multiple-windows onto same or different files.
• Compile and step through errors or Grep and step through finds.
• Goto matching character delimiter ( [ { < which skips comments and quoted matter.
• Goto matching word delimiter, including XML tags and C preprocessor directives.
• Ctrl-arrow key block selection.
• Search and replace system, including regular expression and optional incremental search. Regular expression key for matching balanced C expressions.
• Tags file search (tab completion at tags search prompt uses tags file as database).
• Spell check commands which invoke aspell or ispell. Language for aspell can be passed through editor.
• Paragraph format which preserves news/mail quoting indentation characters.
• Unlimited Undo and Redo.
• Yank buffer allows stepping through and insertion of previously deleted text.
• State file restores history buffers, yank buffer and last file cursor positions.
• Cursor position history allows you to step through previously visited areas of a file.
• Multiple interactive keyboard macros. Macros can be assigned to key sequences in joerc file.
• Block move/copy/delete/filter.
• Rectangle (columnar) block mode- search and replace can be narrowed to the rectangular block. Rectangular blocks can be filtered through UNIX commands.
• Overtype/Insert modes.
• Indent/Unindent (shift block left or right).
• Auto-indent mode.
• Picture mode for ASCII graphics.
• Line number mode displays line number of each line.
• Powerful scientific calculator with block statistics functions (sum/standard-deviation/count highlighted block of numbers).
• Termcap/Terminfo support allows JOE to use any terminal or terminal emulator.
• Can accept data from a pipe, for example: ls | joe


GEDIT
gedit is the official text editor of the GNOME desktop environment.
While aiming at simplicity and ease of use, gedit is a powerful general purpose text editor.
Currently it features:
• Full support for internationalized text (UTF-8)
• Configurable syntax highlighting for various languages (C, C++, Java, HTML, XML, Python, Perl and many others)
• Undo/Redo
• Editing files from remote locations
• File reverting
• Print and print preview support
• Clipboard support (cut/copy/paste)
• Search and replace
• Go to specific line
• Auto indentation
• Text wrapping
• Line numbers
• Right margin
• Current line highlighting
• Bracket matching
• Backup files
• Configurable fonts and colors
• A complete online user manual
gedit features also a flexible plugin system which can be used to dynamically add new advanced features to gedit itself. See the plugins page for more info on the existing plugins.
Go to the screenshots page to see gedit in action!
gedit is released under the GNU General Public License (GPL).

ActiveState Komodo

ActiveState Komodo

Developed by
ActiveState

Stable release
5.1.3 (2009-4-29; 8 days ago) [+/−]

Preview release
none (n/a) [+/−]

Written in
Python, JavaScript, XUL

Operating system
Cross-platform

Available in
English
Type
IDE

License
IDE:Proprietary; Edit: MPL/GPL/LGPL

Website
http://www.activestate.com/komodo/

ActiveState Komodo is the name given to a family of integrated development environment (IDE) applications produced by software firm ActiveState.

Komodo IDE
Komodo IDE is an IDE for dynamic programming languages built on the Mozilla platform. It supports dynamic languages, including JavaScript, Perl, PHP, Python, Ruby, and Tcl; framework stacks like Ruby on Rails and CakePHP; and client libraries such as the Yahoo! UI Library and Dojo.
ActiveState added browser-side support in Komodo IDE 4.0, including debugging, DOM viewer, catalog support, HTTP Inspector, and code intelligence for languages such as JavaScript, CSS, HTML, and XML, enabling programmers to edit and debug Ajax code and multi-language files.
Komodo IDE, although not Open Source, is extensible using standard Mozilla APIs based on XUL, XBL, and XPCOM, plus Python and JavaScript.
Komodo IDE is available for Linux, Mac OS X, and Microsoft Windows platforms.
Komodo Edit
Komodo Edit is a free text editor for dynamic programming languages introduced in January 2007. With the release of version 4.3, Komodo Edit is built on top of the Open Komodo project.
Komodo Edit inherits many features of Komodo IDE, like the full range of supported languages (Perl, PHP, Python, Ruby, Tcl) and platforms (Linux, Mac OS X, and Windows ). And like Komodo IDE, Komodo Edit also supports browser-side languages like JavaScript, CSS, HTML, and XML.
It was developed for programmers who need a multi-language editor with broad functionality, but not the features of an IDE, like debugging, DOM viewer, interactive shells, and source code control integration



REFERENCE CITED

 www.wikipedia.com
 www.linuxforum.com
 www.gedit.com
 Linux Bible
 Encarta encylopedia
 Linux prgramming

No comments:

Post a Comment