Linux

Working with Editors

In this section we will discusses the main text editors you'll see in the Linux world. Now we are going to discuss our first editor.

Vi (visual editor) or VIM (VI iMproved)

This is the classic screen-based editor for UNIX. The vi editor works in two modes, command and insert.
To start vi, simply type
# vi <filename> (you can set absolute path also)
If you want to make a file in /etc/mohit directory then you can give command like this
# vi /etc/mohit/<file name>
If do not specify path then file would be save in current working directory
Linux vi editor
Linux vi editor

In above figure op is file name press enter, next screen would be.
Linux vi editor
Linux vi editor

At this moment vi editor is in command mode if want to write anything press I or insert key.
Now you can type your text.
Linux vi editor in Insert mode
Linux vi editor in Insert mode
After typing if you want to save this, need to enter in command mode.
Press Esc key to enter in command mode.
Press : After this you can specify you aim.
w for save the text
q for quit after save
wq quit after save the text
q! quit without save
Linux vi editor in saving file
Save file in Linux vi editor

Navigation

Navigation is rudimentary thing for test editor. Use following commands for navigation
h left one space
l right one space
j down one space
k up one space
w moves the cursor forward one word.
b moves the cursor backward one word.
H moves the cursor to the top line of the screen.
M moves the cursor to the middle line of the screen.
L moves the cursor to the last line of the screen.

Searching Text in vi editor

In order to search the string in file use the following commands.
/string search forward for occurrence of string in text
?string search backward for occurrence of string in text
n move to next occurrence of search string
N move to next occurrence of search string in opposite direction
Searching string in Linux vi editor
Searching string in Linux vi editor

Copying Text with Yank

In order to make duplicate copy of existing line. You can use yank.
yw copies a word into a buffer (7yw copies 7 words)
yy copies a line into a buffer (3yy will copy 3 lines)

Deleting text

In order to delete text in vi editor use following commands :
x delete one character
dw delete the current word (Note: ndw deletes n numbered words)
dd delete the current line (Note: ndd deletes n numbered lines)

For more command you can see the man page of vi.

emacs

To start emacs, simply type
# emacs
It's big,expandable, feature-rich, and all-around amazing. For GUI people, emacs a pleasant environment to work with at first.

GNOME Editor

The gedit text editor is a basic text editor.
If you do html, python coding in gnome editor then it will show the color for keywords and tags. Starting gedit
# gedit <filename>
Or
# gedit
Now you have learned the editors of Linux file system.




admin