Linux Training

Linux training for private, public & voluntary sector.

0800 024 8425

City LinUX Training Courses

Section 12.
Linux editors
.


"Vi has two modes. The one in which it beeps and the one in which it doesn’t."

Unknown.

12. Linux editors.

There are any number of editors available in Linux. For systems hackers and programmers the choice was often made between emacs or vi.

As more users came to the UNIX / Linux environment from Windows they tended to be unwilling to learn the command structure of editors like vi and looked for more intuitive alternatives which made greater use of the PC’s extended keyboard.

12.1. Pico

Pico became popular through its use with the pine mail user agent.

12.2. Nano

The default editor in Ubuntu is nano, a clone of pico which the Ubuntu man pages describes as "non free". That’s a swipe at the licence used by Washington University rather than indicating that a charge is made for Pico’s use.

12.3. Editors to shake a stick at.

Use a search engine to find some of the available editors in Ubuntu. These include

Image imgs/sa101-11.png

12.4. ed, ex and vi.

In the beginning there was ed. The ed line editor was written in PDP 11/20 assembler in 1971 by Ken Thompson and was one of the first software tools created for the UNIX operating system.

Aspects of ed were included in ex which became one of the engines in the visual editor vi.

Every Linux systems administrator should know the basic ed commands and be able to bail out systems that are otherwise unusable at the command line. It is also useful to be able to incorporate ed in here scripts. (Here scripts are those where the input redirection is from the script itself rather than an external file.)

The syntax of ed is very simple and it takes only a few minutes to learn the basics.

12.5. Example.

sa101# cd /etc
sa101$ head -7 shadow
root:$1$0OzJEaEY$D55n1EnPIPaOK8u0RU89D/:15137:0:::::
bin:*:9797:0:::::
daemon:*:9797:0:::::
adm:*:9797:0:::::
lp:*:9797:0:::::
sync:*:9797:0:::::
shutdown:*:9797:0:::::
sa101# ed shadow
778             #<- number of characters in the file
1s/:[^:]*:/::/  #<- go to line1. Substitute the first expression by the second
w               #<- write the file back to disc
744             #<- number of characters written back to file
q               #<- quit
sa101$ head -7 shadow
root::15137:0:::::
bin:*:9797:0:::::
daemon:*:9797:0:::::
adm:*:9797:0:::::
lp:*:9797:0:::::
sync:*:9797:0:::::
shutdown:*:9797:0:::::

12.6. Using vi.

Vi is the standard System V text editor. It is installed by default on every host based system V UNIX, including all Linux distributions, that I have come across. It is not available as standard in Android although implementations are downloadable.

True vi binaries are not normally found on Linux distributions. Enhanced alternatives are vim, elvis, nvi and vile. The anecdotal evidence would suggest that Vim (Vi IMproved) has become the dominant incarnation in the Linux world.

"Over the years since its creation by Bill Joy, vi became the de facto standard Unix editor and a nearly undisputed hacker favourite outside of MIT, until the rise of Emacs after about 1984. The Single UNIX Specification specifies vi, so.. [ it must be included with every conformant system.].. vi is still widely used by users of the Unix family of operating systems. About half the respondents in a 1991 USENET poll preferred vi. /In 1999, Tim O’Reilly, founder of the eponymous computer book publishing company, stated that his company sold more copies of its vi book than its emacs book.

A 2009 survey of Linux Journal readers found that vi was the most widely used text editor among respondents, beating gedit, the second most widely used editor by nearly a factor of two (36% to 19%)." Wikipedia 2012.

A table of the more common vi commands can be found overleaf.

12.7. Vi commands

 

Image imgs/sa101-12.png

12.8. Exercises.

Complete the training offered by the tutor vimtutor.  


The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.