Let’s say I’m working on an html file, and my cursor is between the open and close tags:
<button>I</button >
when I hit enter, I want vim to automatically format to this:
<button >
I
</button >
I is the cursor position.
I’m thinking about modifying vimrc file, something like:
inoremap <CR> "if previous character is > and next character is <, then <CR>O"
But I don’t know how to get the previous/next character of the cursor.
I hope this makes sense,
I tried to search everywhere but I couldn’t find any help, maybe I’m searching for the wrong keywords, or taking the wrong approach.
1 Answer