Some vim commands

Hi Friends,

HAPPY NEW YEAR This year brings happiness

:recently_I_Learned _some_vim _commands

:i_am_happy_to_share_with_you

Now I would like to share with you some vim commands which i known recently,I hope you can get your commands in direct googling ,but here i would like to share my familiar commands with you

Actually Vim is a powerful editor there are a lot of plugins available even we can maintain a todo list in vim taskpaper is used to do that.

In some previous days i used Vim to open,read,write simple purpose just recent days only i started to use for search,copy for those purposes too
There are a lot of editors available command line utility is the good for programmers like technician
Vim(old) is gold

:  To enter into vim command mode

vim commands only has to be entered in this mode only,so when ever we need to do enter vim commands we should use this colon character
:e file_name To open a file [Eg: :e post.txt]
:tabnew To open new tab
:tabfirst[tablast] Switch to first tab ,last tab respectively
:sav or :w used to save the files
Replace a string in a file

:%s/old_string/new_string/g here the string replacement occurs in all lines of the file

if you want to do this operation in a particular set of lines
:3,44s/old_string/new_string/g

:3,$s/old_string/new_string/g Starting line no 3 to End OF file
:%s/^/start/g Add the String “Start” in all starting lines of your file
:%s/$/end/g Add the String “end” in all ending lines of your file

:g/string/d Delete all lines what has the string
:v/string/d Delete all lines what hasn’t contain the string

:2,45 w another_file.txt // Witre the lines from 2 to 45 to another file
:2,45 w >> another_file.txt //To append those lines to another file
Change Color Scheme
:colorscheme morning [morning,evening,desert….]
Auto-completion
Ctrl+n Ctrl+p (in insert mode)

Complete wordCtrl+x Ctrl+l

Complete line:set dictionary=dict Define dict as a dictionnary

Ctrl+x Ctrl+k Complete with dictionnary

set shiftwidth=3 //for indentation space

set autoindent //auto indent

Would you want to change the Case in all lines of your file
Execute this command in your vim mode
:for i in range(0,line(‘$’))

[“indent need”]call setline(i,tolower(getline(i)))

endfor

Explanation:
Get the No of lines in for loop and call the function setline to set all lines as lowercase similar that we can peroform for toupper(),..
If you want to change the cases in line only
Press ‘V‘(caps)
and press ‘e‘ then press ‘u‘  for small case
press ‘E‘ then press ‘U” for big case

Do in All tabs:

If you want to do your vim commands in all opened tabs means you can use the command tabdo
:tabdo %s/old_string/new_string/g

okay these are the commands which i learnt recenly 😉 I hope this will be useful for you in some way
okay if you find any problem with this means send me for a discussion
thanks!!

Advertisements

About Navaneethan

mixed feelings...
This entry was posted in Fedora, Free Software, Ubuntu. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s