Example output, where |
is the cursor:
function () {
|
};
foo(function () {
|
});
if () {
|
}
Along with else
, for
, and switch
.
Also does this correctly:
var x = {
foo: function () {
|
} // No semi!
}; // Semi!
fun! SemiOrNoSemi() | |
return "{\<cr>}\<c-o>O\<Tab>\<Down>".(getline('.') =~# '^\s*for\s\|if\s\|else\s|switch\s'||getline('.') =~# ':'? '' : ';')."\<up>" | |
endfunction | |
au BufNewFile,BufRead *.js imap <buffer> <expr> {<cr> SemiOrNoSemi() |