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

debug call function() to debug a function in vim

Drawn in Autosketch + pasting in words from Excel
Image via Wikipedia

Have you ever wished that you could either see what is going on initially at the vim startup like you could do with C program in the gdm mode, but really did not want to go through gdb. Or rather you sometime felt that some function defined by some plugin is causing some issue and you wanted to debug just that function. Well you need not wish anymore, the functionality is already there.

 

If you want to debut a function then you can simply call the function in debug mode, while you are in vim mode.

1
 :debug call()

You can use continue/next/quit and finish like in any other debugger out there in the wild.

And if you wanted to debug the startup then you can do this :

1
vim -D

HTH.

You can get more info here.

 

Enhanced by Zemanta

vim autocomplete – automagically without tab.

Table of contents for vim inttellisense

  1. vim autocomplete – automagically without tab.

Lets first do the setup in one line. Get my vim script downloader.

Use the script to add the script with script ID : :1879 (vim-autocomplpop) to your list of plugins for vim and you  are done.

 

If you are using snipmate, then make sure that you read the description of the plugin to add the required lines to the vimrc file to get the full functionality. You would love to type henceforth in your favourite editor. We will talk about more on Intellisense in few days time.. Chao till then.

Enhanced by Zemanta