I'm trying to define a vi 'map' command sequence, that would wrap the current word inside an HTML tag, e.g. the B (bold) tag. The map is defined as follows:
:map K ebi<B><esc>ea</B><esc>
The map starts with the motion "eb" to move to the beginning of the selected word, assuming that the most likely cursor position would be the beginning of the word or in the middle. The problem is, it does not work if the cursor is on the last character of the word - then the following word would be wrapped.
Is there a trick to make this map work reliably for any cursor position with a word?