Text Editor Command

broken image


Ravitz Editor V1.10: Ascii Text Editor With Integrated Outlining/overviewing Capabilities One Character Mnemonic Functions, Commands, & Options, Menus, Mouse Input, And An Online Help System; Cary Ravitz. Type vi filename.txt into Terminal. The 'vi' part of this command selects the Vim text editor as the program to use. You'll replace 'filename' with the name you wish to assign to your new file. For a file named 'tamins', for example, you'd type vi tamins.txt. Convert rich text documents to other formats. With TextEdit, you can open and edit rich text documents created in other word processing apps, including Microsoft Word and OpenOffice. You can also save your documents in a different format, so they're compatible with other apps. How to open, edit, and convert documents. A simple editor to learn is ee (1), which stands for easy editor. To start this editor, type ee filename where filename is the name of the file to be edited. Once inside the editor, all of the commands for manipulating the editor's functions are listed at the top of the display.

  1. Unix Text Editor Commands
  2. Text Editor Command Prompt Windows

Text editors that can be used in a command line interface environment. Nano - small, friendly text editor inspired by Pico. Vim - A full-featured editor with syntax highlighting. Emacs - the extensible self-documenting text editor( high learning curve) mc - Midnight Commander provides an internal text editor (mc -e,mcedit).

Commands

On Linux, you have a choice of text editors. Some are easy-to-use but have limited functionality; others require training to use and take a long time to master, but offer incredible functionality.

Desktop graphical editors

Text Editor

When using Raspberry Pi OS Desktop, in the accessories menu there is an option to run a Text Editor. This is a simple editor which opens in a window like a normal application. It allows use of the mouse and keyboard, and has tabs and syntax highlighting.

You can use keyboard shortcuts, such as Ctrl + S to save a file and Ctrl + X to exit.

Thonny

Text

On Linux, you have a choice of text editors. Some are easy-to-use but have limited functionality; others require training to use and take a long time to master, but offer incredible functionality.

Desktop graphical editors

Text Editor

When using Raspberry Pi OS Desktop, in the accessories menu there is an option to run a Text Editor. This is a simple editor which opens in a window like a normal application. It allows use of the mouse and keyboard, and has tabs and syntax highlighting.

You can use keyboard shortcuts, such as Ctrl + S to save a file and Ctrl + X to exit.

Thonny

Thonny is a Python REPL and IDE, so you can write and edit Python code in a window and run it from there.

Thonny has independent windows and syntax highlighting, and uses Python 3

GVim

See Vim below.

Geany

A fast and lightweight IDE, supporting many different file types, including C/C++ and Python. Installed by default on Raspberry Pi OS.

Command-line editors

Nano

GNU Nano is at the easy-to-use end of command-line editors. It's installed by default, so use nano somefile.txt to edit a file, and keyboard shortcuts like Ctrl + O to save and Ctrl + X to exit.

Vi

Vi is a very old (c. 1976) command-line editor, which is available on most UNIX systems and is pre-installed on Raspberry Pi OS. 32 bit bluestacks. It's succeeded by Vim (Vi Improved), which requires installation.

Unlike most editors, Vi and Vim have a number of different modes. When you open Vi with vi somefile.txt, you start in command mode which doesn't directly permit text entry. Press i to switch to insert mode in order to edit the file, and type away. To save the file you must return to command mode, so press the Escape key and enter :w (followed by Enter), which is the command to write the file to disk.

To search for the word 'raspberry' in a file, make sure you're in command mode (press Escape), then type /raspberry followed by n and N to flick forwards/backwards through the results.

To save and exit, enter the command :wq. To exit without saving, enter the command :q!.

Depending on your keyboard configuration, you may find your cursor keys don't work. In this case, you can use the H-J-K-L keys (which move left, down, up, and right respectively) to navigate the file in command mode.

Vim

Vim is an extension of Vi and works in much the same way, with a number of improvements. Only Vi is installed by default so to get the full features of Vim, install it with APT:

You can edit a file in Vim with vim somefile.txt. Vim also has a graphical version which opens in a window and allows interaction with the mouse. This version is installable separately:

To use the graphical version of Vim, use gvim somefile.txt. You can save configuration in a .vimrc file in your user's home directory. To learn more about editing in Vi and Vim, you can run vimtutor and follow the tutorial.

Emacs

Emacs is a GNU command-line text editor; it's powerful, extensible, and customisable. You can install it with APT:

You can use keyboard combination commands, such as Ctrl + X Ctrl + S to save and Ctrl + X Ctrl + C to close.

Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

  1. Using the Text Editors
< BackPage 3 of 7Next >
This chapter is from the book
Ubuntu Unleashed 2008 Edition: Covering 8.04 and 8.10, 4th Edition

This chapter is from the book

This chapter is from the book

Ubuntu Unleashed 2008 Edition: Covering 8.04 and 8.10, 4th Edition

Using the Text Editors

Linux distributions include a number of applications known as text editors that you can use to create text files or edit system configuration files. Text editors are similar to word processing programs, but generally have fewer features, work only with text files, and might or might not support spell checking or formatting. The text editors range in features and ease of use, but are found on nearly every Linux distribution. The number of editors installed on your system depends on what software packages you've installed on the system.

Some of the console-based text editors are

  • emacs—The comprehensive GNU emacs editing environment, which is much more than an editor; see the section 'Working with emacs' later in this chapter

  • joe—Joe's Own Editor, a text editor, which can be used to emulate other editors

  • nano—A simple text editor similar to the pico text editor included with the pine email program

  • vim—An improved, compatible version of the vi text editor (which we call vi in the rest of this chapter because it has a symbolic link named vi and a symbolically linked manual page)

Note that not all text editors described here are screen oriented. Some of the text editors for the X Window System, which provide a graphical interface, such as menu bars, buttons, scrollbars and so on, are

  • gedit—A GUI text editor for GNOME

  • kate—A simple KDE text editor

  • kedit—Another simple KDE text editor

A good reason to learn how to use a text-based editor, such as vi, is that system maintenance and recovery operations generally never take place during X Window sessions (negating the use of a GUI editor). Many larger, more complex and capable editors do not work when Linux is booted to its single-user or maintenance mode. If anything does go wrong with your system, you probably won't be able to get into the X Window system, making knowledge and experience of using both the command line and text editors such as vi important. Make a point of opening some of the editors and playing around with them; you never know—you might just thank me someday!

Another reason to learn how to use a text-based editor under the Linux console mode is so that you can edit text files through dial-up or network shell sessions because many servers do not host graphical desktops.

Working with vi

The editor found on nearly every Unix and Linux system is, without a doubt, the vi editor, originally written by Bill Joy. This simple-to-use but incredibly capable editor features a somewhat cryptic command set, but you can put it to use with only a few commands. Although more experienced Unix and Linux users continue to use vi extensively during computing sessions, many newer users might prefer learning an easier-to-use text editor such as pico or GNU nano. Die-hard GNU fans and programmers definitely use emacs.

That said, learning how to use vi is a good idea. You might need to edit files on a Linux system with a minimal install, or a remote server without a more extensive offering of installed text editors. Chances are better than good that vi will be available.

You can start an editing session by using the vi command like this:

The vi command works by using an insert (or editing) mode, and a viewing (or command) mode.

When you first start editing, you are in the viewing mode. You can use your cursor or other navigation keys (as shown later) to scroll through the text. To start editing, press the i key to insert text or the a key to append text. When finished, use the Esc key to toggle out of the insert or append modes and into the viewing (or command) mode. To enter a command, type a colon (:), followed by the command, such as w to write the file, and press Enter.

Although vi supports many complex editing operations and numerous commands, you can accomplish work by using a few basic commands. These basic vi commands are

  • Cursor movement—h, j, k, l (left, down, up, and right)

  • Delete character—x

  • Delete line—dd

  • Mode toggle—Esc, Insert (or i)

  • Quit—:q

  • Quit without saving—:q!

  • Run a shell command—:sh (use 'exit' to return)

  • Save file—:w

  • Text search—/

Working with emacs

Richard M. Stallman's GNU emacs editor, like vi, is included with Ubuntu and nearly every other Linux distribution. Unlike other Unix and Linux text editors, emacs is much more than a simple text editor—it is an editing environment and can be used to compile and build programs, act as an electronic diary, appointment book and calendar, compose and send electronic mail, read Usenet news, and even play games. The reason for this capability is that emacs contains a built-in language interpreter that uses the Elisp (emacs LISP) programming language. emacs is not installed in Ubuntu by default; instead you'll need to install it using apt-get or synaptic. The package you need is simply emacs.

Unix Text Editor Commands

You can start an emacs editing session like this_FIRST:

The emacs editor uses an extensive set of keystroke and named commands, but you can work with it by using a basic command subset. Many of these basic commands require you to hold down the Ctrl key, or to first press a meta key (generally mapped to the Alt key). The basic commands are listed in Table 4.2.

Table 4.2. Emacs Editing Commands

Text Editor Command Prompt Windows

Action

Command

Abort

Ctrl+g

Cursor left

Ctrl+b

Cursor down

Ctrl+n

Cursor right

Ctrl+f

Cursor up

Ctrl+p

Delete character

Ctrl+d

Delete line

Ctrl+k

Go to start of line

Ctrl+a

Go to end of line

Ctrl+e

Help

Ctrl+h

Quit

Ctrl+x, Ctrl+c

Save As

Ctrl+x, Ctrl+w

Save file

Ctrl+x, Ctrl+s

Search backward

Ctrl+r

Search forward

Ctrl+s

Start tutorial

Ctrl+h, t

Undo

Ctrl+x, u





broken image