This is my ~/.vimrc (moved the real one out of the way):
inoremap d You pressed D<Enter> inoremap <PageUp> You pressed PageUp<Enter> inoremap <PageDown> You pressed PageDown<Enter> inoremap <C-D> You pressed Ctrl+D<Enter> For d and Ctrl+D it works as expected, but for Page Up and Page Down the default behavior kicks in and the configured text is not written into the buffer.
Mapping the ESC sequences directly work as expected:
inoremap <Esc>[5~ You pressed PageUp2<Enter> inoremap <Esc>[6~ You pressed PageDown2<Enter> Any idea why remapping using <PageUp> and <PageDown> doesn't work?
Additional information as requested in comments:
1. Following the advice from How to debug a mapping?
Output of :map doesn't show any of those mappings (or any conflicting mappings for that matter). :imap does show all four mappings exactly the same as :verbose imap does (except for missing the verbose part):
modifyOtherKeys detected: On i <C-D> * You pressed Ctrl+D<CR> Last set from ~/.vimrc line 4 i <PageDown> * You pressed PageDown<CR> Last set from ~/.vimrc line 3 i <PageUp> * You pressed PageUp<CR> Last set from ~/.vimrc line 2 i d * You pressed D<CR> Last set from ~/.vimrc line 1 2. What does :verbose imap <PgDown> show?
:verbose imap <PgDown> doesn't show the mapping for PageDown:
modifyOtherKeys detected: On No mapping found However, :verbose imap <PageDown> does show it:
modifyOtherKeys detected: On i <PageDown> * You pressed PageDown<CR> Last set from ~/.vimrc line 3 And adding a mapping for <PgDown> causes it to show up as well:
modifyOtherKeys detected: On i <PgDown> * You pressed PgDown<CR> Last set from ~/.vimrc line 5 3. What is your terminal and what is the value of TERM?
I use xterm. The command
set | grep "^[^ ]*TERM" shows
TERM=xterm XTERM_LOCALE=C XTERM_SHELL=/bin/bash XTERM_VERSION='XTerm(388)' After xterm upgrade to 396, the problem persists, the above command now shows
XTERM_VERSION='XTerm(396)' along with the other three lines.
4. Try xterm-16color and xterm-256color
Neither changes the problem in Vim.
imapcommand (and some additional stuff regarding that) @VivianDeSmedt<Esc>[5~and<Esc>[6~which both work as expected. This will be my workaround for the time being.:echo $TERM?