1

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.

12
  • 1
    Start with How to debug a mapping Commented Jan 15 at 22:46
  • 1
    I added the output of your imap command (and some additional stuff regarding that) @VivianDeSmedt Commented Jan 16 at 1:00
  • 1
    Thinking about how to debug this I came up with an attempt to map <Esc>[5~ and <Esc>[6~ which both work as expected. This will be my workaround for the time being. Commented Jan 16 at 1:42
  • 1
    what is your terminal emulator and what is the output of :echo $TERM? Commented Jan 16 at 2:05
  • 1
    Or you could post it right now and give the subject a rest. Commented Jan 17 at 7:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.