how to use vim to automatically format xml tags when I press 'enter'? Should I write a plugin or modify vimrc? -
how to use vim to automatically format xml tags when I press 'enter'? Should I write a plugin or modify vimrc? -
let's i'm working on html file, , cursor between open , close tags:
<button>i</button >
when nail enter, want vim automatically format this:
<button > </button >
i
cursor position.
i'm thinking modifying vimrc file, like:
inoremap <cr> "if previous character > , next character <, <cr>o"
but don't know how previous/next character of cursor.
i hope makes sense, tried search everywhere couldn't find help, maybe i'm searching wrong keywords, or taking wrong approach.
inoremap <expr> <cr> '<cr>' . (search('\v>\%#<','bcn') ? '<esc>o' : '')
vim
Comments
Post a Comment