Reputation: 2480
For a function, it would be something like
function {
|
}
I'm using the vim-closetag plugin, which works fine, but for tags such as head
which is often styled like such,
<head>
|
</head>
vim-closetag doesn't automatically do this, instead it does
<head>|</head>
Some tags are fine like this, but can I map a command to style the tag like the previous style, line between open and close tag.
Right now I have to manually format it
Upvotes: 0
Views: 164
Reputation: 32966
In C&C++, I have {
expanded in to {|}
. I insert the two \n
only when I hit enter from within a pair of curly-brackets. This way I can decide when I want to go to a new line, or when want oneliners.
You should be able to do the same with html/xml tags.
inoremap <buffer> <expr> <cr> getline(".")[col(".")-2:col(".")-1]=="><" ? "<cr><esc>O" : "<cr>"
(to be defined in a ftplugin)
Upvotes: 1