0

I use F12 on the Mac (10.11.6) I've mapped F12 to:

 map! ^[[24~ <ESC>:w<CR>a

to write my file and return to adding text.

When I use this mapping I see "Insert" on the status line. Is there a way to delay before the insert begins so the file name is visible as when one does a manual <ESC>:w?

1 Answer 1

1

This is not really possible, because as soon as your map finishes, you are left in insert mode so you see the 'showmode' message. There are a couple of alternatives however.

a) Fancy statusline plugins like vim-airline usually also display the mode, so one does not necessarily need the option 'showmode' anymore: :set noshowmode

b) Increase your 'cmdheight' setting to 2: :set cmdheight=2 so that both messages can be displayed simultaneously.

Please note you can use the keyname instead of the keycode for your mapping. So in your example, you might want to use imap <f12> <c-\><c-o>:w<cr> (note instead of using esc to return from insert mode, I used the CTRL\CTRLO to temporarily switch for one command to normal mode.

1
  • Christian, solution b is exactly what I needed (simple/effective). FYI: The reason I used the literal string for <F12> is that on my Mac (10.11.6), <F12> simply didn't work.
    – jeffb
    Commented Mar 14, 2017 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.