Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have the following handy VIM map:

inoremap ( ()<Left>

However, sometimes I will enter Insert mode to add a function call around a variable, like so:

Was: $sql = "SELECT * FROM " . $someTable;
 To: $sql = "SELECT * FROM " . mysql_real_escape_string($someTable);

The mapping makes a redundant ) after mysql_real_escape_string(. Is there any way to refactor the mapping so that if there exists a character after the cursor, and the character after the cursor is not whitespace, then )<left> is not appended to (?

Thanks.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Doing that would mean entering "function territory". From there, why not go full gear into "plugin territory" and use a dedicated plugin like delimitmate or autoclose or the many variations on the same idea?

share|improve this answer
    
Thank you, I will take a look at those plugins. –  dotancohen Oct 31 '12 at 14:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.