vim mappings – easy way to do things.

You can use vim mappings to make some of your editor tasks very simple. Here I am giving you just a example, but you could always let your imagination run wild.

:nmap ,b Oj0c$**hP

And what do we do here.

O – Add a new line

– Go to normal mode

j – go to newly added line

0 – Go to begining of line

c$ – Change till end of line

****<Esc> РEnter  four stars

h – go back one character.

P –¬† Paste the last deleted line, which is what we deleted with c$.

This is just to show you how powerful, mappings can be. So, GO WILD with imagination.

 

Enhanced by Zemanta

vim maps – simple commands to do stuff.

Some time back, I was working on some script for logging and I wanted to change the class to function like this:

$logger->Debug("Test string");
loggerFunc("Debug", "Test String");

As you can see, this change could be quite frustrating if you have quite a few references. And thus vim comes to rescue.

Simple map like ::

:map ,mm :s/(.*)$logger->(.*)((.*)).*/1loggerFunc("2",3);/

and then I can do “/$logger->” and then “n” to go to next match. Just do “,mm” and the line is re-factored.

Break down of the regex :

.* :search for any spaces before $logger->

(.*) :match anything

( : upto (

(.*) :match anything

) : till )

and then replace as required.

 

Enhanced by Zemanta

when you press f9 \’paste\’ is on , press f9 again and \’paste\’ is off, and so forth (works in insert-mode and command-mode)


vim\’s pastetoggle: when you press f9 \’paste\’ is on , press f9 again and \’paste\’ is off, and so forth (works in insert-mode and command-mode) $ nmap :set paste!:set paste? Sets as paste toggle, with visual confirmation of state

* View this command to comment, vote or add to favourites * View all commands by Vilemirth

commandlinefu.com

by David Winterbottom (codeinthehole.com)

URL: http://feedproxy.google.com/~r/Command-line-fu/~3/jGHf9FmLuUI/vims-pastetoggle-when-you-press-f9-paste-is-on-press-f9-again-and-paste-is-off-and-so-forth-works-in-insert-mode-and-command-mode

\"Enhanced