Abbreviations override in comments and quoted text
- by dotancohen
I have the following handy abbreviation in VIM:
iab for for<Space>(<Space>{{<Esc>kA<Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
This nicely replaces for with the following text:
for ( ) {
}
However, I would like this abbreviation to work only in code, not in comments or in single- or double- quoted strings. How might this constraint be accomplished?
Note that I usually code in PHP, but often enough I find myself in other C-style languages (C, Java, occasional C#, etc.). Preventing the abbreviation from working in Python would be a nice bonus though I don't mind manually turning it off in Python if that is not an option. Thanks!