Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 (?


share|improve this question
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

Your Answer


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.