How do I get vim to place the cursor within the braces starting on a new line, ie with | denoting the cursor position :
class {
|
}
right now
I wrote this in my .vimrc
inoremap InsertMapForEnter()
function! InsertMapForEnter()
if pumvisible()
return "\"
elseif strcharpart(getline('.'),getpos('.')[2]-1,1) == '}'
return "\\O"
elseif strcharpart(getline('.'),getpos('.')[2]-1,2) == ''
return "\\O"
else
return "\"
endif
endfunction
The code above first check if you are using Enter
to do confirm a code completion, if not it will indent the {|}
when you type Enter
. Also, it provides html tags auto indent.
For your problem:
class {|}
press Enter
and you will get
class {
|
}
|
press Enter
and you will get
|