Text Editors
Text Editors
WITH
TEXT EDITORS
LINUX & SCRIPTING
Mr. RAM
TEXT EDITORS:
Linux comes with several applications that can be used to write and edit
program code.
You can constantly need to edit config files, write scripts, change system
files…all required to use a text editor.
The most popular text editors are:
vi / vim editor
nano
gedit
emacs
kate / kwrite
lime text
pico edito
VI / VIM EDITOR:
Vi / Vim is a powerful shell prompt text editor. That means doesn’t open a
GUI window.
It is most popular and widely used text editors among system administrators
and programmers.
It enables syntax highlighting when writing code or editing configuration
files.
Vi / VIM follows three modes. There are:
Command mode
Insert mode
Colon or execution mode
NOTE: The command mode is default.
NAVIGATION OPTIONS:
h : cursor left
j : cursor down
k : cursor up
l : cursor right
b : cursor to beginning of current word
e : cursor to end of current word
0 (zero) : go to beginning of line
$ : Cursor goes to end of the current line
^ : Cursor goes to begging of current line
u : Undo whatever you did
r : Replace single character
gg (ngg) : Go to first line in a file / nth line of a file
G (nG) : Last line in file
v : select text
V : select line
LINUX & SCRIPTING
Mr. RAM
SEARCHING:
/cloud : search the file for "cloud". This will highlight all
matches in the editor for you to see.
?cloud : search the file for "cloud".
n/N : find next / previous occurrence of search word
LINE NUMBERS:
:se nu : Set line numbers
:se nonu : Remove line numbers
:n : go to nth line
NANO EDITOR:
Text editing is essential to Linux users. Historically, the Vim text editor has
been the default tool for managing file contents.
Today, many systems and sysadmins prefer to use the nano text editor.
Nano is quite a bit more intuitive than Vim, but it's still worth taking a brief
look at its most fundamental features.
You must be able to accomplish the following four tasks with nano:
Create/open a file
Edit the file
Save changes
Exit the file
LINUX & SCRIPTING
Mr. RAM
SAVE A FILE:
The Ctrl key activates nano's commands on your keyboard.
There is an abbreviated list of commands displayed at the bottom of the nano
interface, and these cover most basic needs.
You "write out" a file to save its contents by using Ctrl+O.
EXIT NANO:
If you examine the list of available commands at the bottom of nano's
interface, you discover that you won't "quit" nano, but instead "exit" nano by
using Ctrl+X.