Text Editors
Text Editors
Features of an Editor
A text editor allows you to perform some of the following
basic functions:
Creating a file
Opening an existing file
Copying and pasting text
Searching text
Handling large amount of data
Action
Moves cursor to previous character.
dd
Deletes line.
:wq+Enter
:w+Enter
:q!+Enter
:e <filename>+Enter
:w <filename>+Enter
:w! <filename>+Enter
:! <command name>+Enter
Action
Ctrl+d or D
Ctrl+u or U
Ctrl+F
Ctrl+B
nG
0 (zero)
Z+Enter
z-
Description
Enables you to read another file, file_name, into the current
file. The content of the file, file_name, is placed after the
cursor position in a new line.
:r !cmd_name
:5,10w file_name
:n#
Enables you to edit the previous file if multiple files are open.
This command enables you to toggle between two files.
Action
rx
Rtext
Action
Action
dw
Deletes word.
dd
Deletes line.
cw
Changes word.
cc
Changes line.
Joins lines.
.(dot)
Action
Places the yanked text after current cursor
position. This command is similar to the paste
operation in Windows.
Places the yanked text before the current
cursor position.
Pattern-finding Commands
The commands for pattern-finding are listed in the following
table.
Command
Action
fx
Fx
/pattern +Enter
?pattern +Enter
Configuring Vi
You can customize the way in which the vi or Vim editor
behaves.
You can use various escape mode commands to change
the behavior of the vi editor.
The three escape mode commands are:
set
map
ab (abbreviation)
Configuring Vi (Contd.)
The various options available with the set command are:
autoindent
ignorecase
magic
number
showmode
showmatch
tabstop=n
wrapscan
Configuring Vi (Contd.)
The map command is also used to customize the vi editor.
The syntax to use the map command is:
:map <the key, which needs mapping> <key
sequence which is to be mapped>
Action
Moves to the previous character.
Moves to the next character.
Moves up one line.
Moves down one line.
Moves to the next screen.
Moves to the previous screen.
Moves to the beginning of the line.
Moves to the end of the line.
Enters the emacs online Help.
Searches forward for a string.
Undoes the last edit.
Exits emacs.
Saves the file.
Cancels the current command.
Deletion Commands
The deletion commands are listed in the following table.
Command
Action
Ctrl+d
Deletes character.
Ctrl+k
Deletes line.
Action
Ctrl+@
Marks text.
Ctrl+w
Ctrl+y
Action
Loads a new file in the memory.
Switches between loaded files.
You can switch between the files that are open, and save or
close individual files.
Spell Check
You can also check the spelling of a word by using the
ispell utility of the emacs editor.
The following figure displays the screen from the spell
check option.