Showing posts with label VIM. Show all posts
Showing posts with label VIM. Show all posts

How to install vim in fedora centos redhat

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to install vim editor in Fedora/CentOS/Redhat? (RPM distributions)

Install VIM editor
[root@server ~]# yum -y install vim-enhanced



Syntax to edit a file using vim
#vim <file name>
Eg: [root@server ~]# vim /etc/dhcp/dhcpd.conf


Configure VIM editor
VIM configuration file is located in "/etc/vimrc". Any changes to this configuration file is applicable for all users. 


Few usefull parameters to add to "/etc/vimrc"
set backup                       #(keep a backup of the editing file)
set backupdir=~/backup    #(specify backup directory)
set history=100                 #(keep 100 search histories)
set number                       #(set number for each line in the file)

How to install vim in Ubuntu

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to install vim text file editor in Ubuntu linux?

VIM is the most compatible and widely used advanced text editor for Linux under GPL License. VIM is the improved version of "VI" editor. Vim is most suitable for all kinds for text based editing like configuration file editing. A GUI based VIM editor named "VIM-Gnome" is also available.


Install full vim editor in Ubuntu
user@ubuntu:~$ sudo apt-get install vim

Install Gnome GUI based vim editor in Ubuntu
user@ubuntu:~$ sudo apt-get install vim-gnome




VIM file editing shortcuts and tips

VIM commands short-cuts and usefull tips  (RPM based Linux)
     VIM is a popular open source text editing tool in Unix like operating systems. Vim can be used to edit all the configuration files in linux.  
Syntax to edit a text file with vim tool: vim<space><filename>
Eg: [root@server ~#]vim /tmp/logfile.txt

#Verify VIM package installed in your machine
[root@server ~#]rpm -q vim-enhanced
#Command to Install the vim package from yum
[root@server ~#]yum -y install vim-enhanced


VIM COMMANDs AND SHORTKEYS (Quick reference)



Command/ key. Action

SAVING AND EXITING
1 :x Save with all changes made and exit
2 :wq Save with all changes made and exit
3 :q! Exit without saving changes.
4 :w Save the changes made so far and continue editing
5 :q Quit the editer if no changes made

CURSER MOVEMENTS
6 w Jump to first letter of next word
7 W Jump to first letter of next coma separated word
8 e Jump to last letter of next word
9 E Jump to last letter of next coma separated word
10 b Jump to first letter of previous word
11 B Jump to first letter of previous coma separated word
12 0 Go to the starting point of current line
13 $ Go to the ending point of current line
14 G Go to the last line of the file
15 L Go to the last line in the screen
16 H Go to the first line in the screen
17 :se nu Set numbers for each lines in the file
18 :n Go the n'th line ( to go to 200th line type :200)

EDITING
19 i or I or a or        "Insert key" Go to insert mode (for editing)
20 O Open a blank line above the current line
21 "Esc" (key) Exit from insert mode
22 dd  Delete the current line
23 X or "Delete key" Delete the letter BEFORE the curser
24 yy Copy the current line
25 nyy   (n = number) Copy the n line.   eg:  7yy for copying 7 lines (from the current line to downwards)
26 p Paste the copied text
27 u Undo
28 Ctr+r Redo
ENCRYPTION
29 :X Encrypt the file with a key
SEARCHING
30 /<keyword> Search the keyword in the file
31 # Search the current word under curser
32 N To display next searched keyword upwards
33 n To display next searched keyword downwards

Replacing words

Switches Purpose
34 c Confirm each action
35 i Ignore case sensitivity
36 % Consider the whole file
37 n Consider the n'th line only

Examples
38 :%s/Jan/new/g Replace every word  "Jan" with "new" in the whole file 
39 :11s/Jan/new/g Replace every  word  "Jan"  with  "new"  in the 11th line of the file
40 :%s/Jan/new/gi Same as above but not case sensitive
41 :s/Jan/new/g Replace every  word  "Jan"  with  "new" only in the current line
42 :%s/Jan/new/gc Replace every  word  "Jan"  with  "new"  in the whole file with confirmation before replacing.

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons