(This question pertains to nvi
instead of vim
.)
To facilitate editing, I created the following mappings
map! ( (?)@^[F?xi
map! [ [?]@^[F?xi
map! { {?}@^[F?xi
so that entering (
will insert (|)@
, where |
denote the cursor position (in insert mode).
Now, what I want is that when I press <TAB>
, the cursor will jump to the @
, delete it, and go into insert mode. For this, I created the mapping
map! ^V^I ^[f@xi
But this works only when @ is not the last character in the line. Likewise,
map! ^V^I ^[f@xa
only works when @ is the last character in the line.
The problem is that the position of the cursor after x
is different depending on whether the last character was removed.
What would solve this problem is if there is another command α
(say) such that α
acts as i
or a
depending the cursor is at the end of the line; as far as I know, no such α
exists.
What can I do?