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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -