justin
justin

Reputation: 3607

Vim use 'a' like 'r'

Is there a way to insert a single character like when r is used, but to append it after the cursor like when a is used (and return to command mode)?

e.g.

Some t[e]xt  " cursor on e (in command mode)
Some te[x]t  " input command I'm looking for, cursor on x and in insert mode
Some te[s]t  " type s and go back to command mode

Upvotes: 2

Views: 115

Answers (2)

Daan Bakker
Daan Bakker

Reputation: 6332

Here's another interesting way it could be done. Unlike other solutions, this one actually lets you type the character in insert mode and automatically reverts back to normal mode:

fun! s:InsertSingle()
  aug insertSingle
    au CursorMovedI * stopinsert | au! insertSingle
  aug END
  return 'a'
endf

nnoremap <expr> <space> <SID>InsertSingle()

Upvotes: 1

hlopko
hlopko

Reputation: 3270

is this what you're looking for?

http://vim.wikia.com/wiki/Insert_a_single_character

Upvotes: 3

Related Questions