After several trys and reading of the documentation I don't think this mapping is possible. Citing from :help abbreviations
:
There are three types of abbreviations:
full-id The "full-id" type consists entirely of keyword characters (letters
and characters from 'iskeyword' option). This is the most common
abbreviation.
Examples: "foo", "g3", "-1"
end-id The "end-id" type ends in a keyword character, but all the other
characters are not keyword characters.
Examples: "#i", "..f", "$/7"
non-id The "non-id" type ends in a non-keyword character, the other
characters may be of any type, excluding space and tab. {this type
is not supported by Vi}
Examples: "def#", "4/7$"
Examples of strings that cannot be abbreviations: "a.b", "#def", "a b", "_$r"
So an abbreviation like <script
seems to be impossible. You could of course define an abbreviation for script
like this:
:inoreabbrev script <script type="text/javascript"></script>
This way the opening bracket isn't part of the abbreviation and so it is also not needed in the expansion. The only problem is that you have to be careful when you want to write the text script
. In that case you have to switch out of insert mode in the middle of the word or type script<C-V><space>
.
Another useful trick to place the cursor in between the tags is a mapping like this, which jumps backwards to the previous opening bracket:
:inoreabbrev script <script type="text/javascript"></script><C-O>F<
Or, to place the tags on different lines with the cursor between them:
:inoreabbrev script <script type="text/javascript"><CR></script><C-O>O