Skip to content
Browse files

Add function key support for TERM=linux and TERM=putty*.

  • Loading branch information...
1 parent c4018ff commit bb61dc9f24bffe2fe9edf557dffef2141a05ea48 @drmikehenry drmikehenry committed Oct 8, 2012
Showing with 156 additions and 0 deletions.
  1. +96 −0 termsupport.vim
  2. +57 −0 termtest.vim
  3. +3 −0 vimrc
View
96 termsupport.vim
@@ -0,0 +1,96 @@
+" vim:tw=80:ts=4:sts=4:sw=4:et:ai
+
+" On all terminals, have F1 through F12 and S-F3 through S-F8.
+
+if $TERM =~ "^putty"
+
+ " Default mode (ESC [n~).
+ map <ESC>[11~ <F1>
+ map <ESC>[12~ <F2>
+ map <ESC>[13~ <F3>
+ map <ESC>[14~ <F4>
+ map <ESC>[15~ <F5>
+ map <ESC>[17~ <F6>
+ map <ESC>[18~ <F7>
+ map <ESC>[19~ <F8>
+ map <ESC>[20~ <F9>
+ map <ESC>[21~ <F10>
+ map <ESC>[23~ <F11>
+ map <ESC>[24~ <F12>
+ map! <ESC>[11~ <F1>
+ map! <ESC>[12~ <F2>
+ map! <ESC>[13~ <F3>
+ map! <ESC>[14~ <F4>
+ map! <ESC>[15~ <F5>
+ map! <ESC>[17~ <F6>
+ map! <ESC>[18~ <F7>
+ map! <ESC>[19~ <F8>
+ map! <ESC>[20~ <F9>
+ map! <ESC>[21~ <F10>
+ map! <ESC>[23~ <F11>
+ map! <ESC>[24~ <F12>
+
+ " For unfathomable reasons, <S-F1> and <S-F2> are the same as
+ " <F11> and <S-F12>, so they are skipped.
+ map <ESC>[25~ <S-F3>
+ map <ESC>[26~ <S-F4>
+ map <ESC>[28~ <S-F5>
+ map <ESC>[29~ <S-F6>
+ map <ESC>[31~ <S-F7>
+ map <ESC>[32~ <S-F8>
+ map <ESC>[33~ <S-F9>
+ map <ESC>[34~ <S-F10>
+ map! <ESC>[25~ <S-F3>
+ map! <ESC>[26~ <S-F4>
+ map! <ESC>[28~ <S-F5>
+ map! <ESC>[29~ <S-F6>
+ map! <ESC>[31~ <S-F7>
+ map! <ESC>[32~ <S-F8>
+ map! <ESC>[33~ <S-F9>
+ map! <ESC>[34~ <S-F10>
+endif
+
+if $TERM == "linux"
+ map <ESC>[[A <F1>
+ map <ESC>[[B <F2>
+ map <ESC>[[C <F3>
+ map <ESC>[[D <F4>
+ map <ESC>[[E <F5>
+ map <ESC>[17~ <F6>
+ map <ESC>[18~ <F7>
+ map <ESC>[19~ <F8>
+ map <ESC>[20~ <F9>
+ map <ESC>[21~ <F10>
+ map <ESC>[23~ <F11>
+ map <ESC>[24~ <F12>
+ map! <ESC>[[A <F1>
+ map! <ESC>[[B <F2>
+ map! <ESC>[[C <F3>
+ map! <ESC>[[D <F4>
+ map! <ESC>[[E <F5>
+ map! <ESC>[17~ <F6>
+ map! <ESC>[18~ <F7>
+ map! <ESC>[19~ <F8>
+ map! <ESC>[20~ <F9>
+ map! <ESC>[21~ <F10>
+ map! <ESC>[23~ <F11>
+ map! <ESC>[24~ <F12>
+
+ map <ESC>[25~ <S-F1>
+ map <ESC>[26~ <S-F2>
+ map <ESC>[28~ <S-F3>
+ map <ESC>[29~ <S-F4>
+ map <ESC>[31~ <S-F5>
+ map <ESC>[32~ <S-F6>
+ map <ESC>[33~ <S-F7>
+ map <ESC>[34~ <S-F8>
+ " The linux console doesn't provide <S-F9> through <S-F12>.
+ map! <ESC>[25~ <S-F1>
+ map! <ESC>[26~ <S-F2>
+ map! <ESC>[28~ <S-F3>
+ map! <ESC>[29~ <S-F4>
+ map! <ESC>[31~ <S-F5>
+ map! <ESC>[32~ <S-F6>
+ map! <ESC>[33~ <S-F7>
+ map! <ESC>[34~ <S-F8>
+endif
View
57 termtest.vim
@@ -0,0 +1,57 @@
+" vim:tw=80:ts=4:sts=4:sw=4:et:ai
+
+" Source this from vimrc via:
+" runtime termtest.vim
+
+" Map keys for testing in normal and insert modes:
+
+map <S-F1> :echo "S-F1"<CR>
+map <S-F2> :echo "S-F2"<CR>
+map <S-F3> :echo "S-F3"<CR>
+map <S-F4> :echo "S-F4"<CR>
+map <S-F5> :echo "S-F5"<CR>
+map <S-F6> :echo "S-F6"<CR>
+map <S-F7> :echo "S-F7"<CR>
+map <S-F8> :echo "S-F8"<CR>
+map <S-F9> :echo "S-F9"<CR>
+map <S-F10> :echo "S-F10"<CR>
+map <S-F11> :echo "S-F11"<CR>
+map <S-F12> :echo "S-F12"<CR>
+map! <S-F1> :echo "S-F1"<CR>
+map! <S-F2> :echo "S-F2"<CR>
+map! <S-F3> :echo "S-F3"<CR>
+map! <S-F4> :echo "S-F4"<CR>
+map! <S-F5> :echo "S-F5"<CR>
+map! <S-F6> :echo "S-F6"<CR>
+map! <S-F7> :echo "S-F7"<CR>
+map! <S-F8> :echo "S-F8"<CR>
+map! <S-F9> :echo "S-F9"<CR>
+map! <S-F10> :echo "S-F10"<CR>
+map! <S-F11> :echo "S-F11"<CR>
+map! <S-F12> :echo "S-F12"<CR>
+
+map <F1> :echo "F1"<CR>
+map <F2> :echo "F2"<CR>
+map <F3> :echo "F3"<CR>
+map <F4> :echo "F4"<CR>
+map <F5> :echo "F5"<CR>
+map <F6> :echo "F6"<CR>
+map <F7> :echo "F7"<CR>
+map <F8> :echo "F8"<CR>
+map <F9> :echo "F9"<CR>
+map <F10> :echo "F10"<CR>
+map <F11> :echo "F11"<CR>
+map <F12> :echo "F12"<CR>
+map! <F1> :echo "F1"<CR>
+map! <F2> :echo "F2"<CR>
+map! <F3> :echo "F3"<CR>
+map! <F4> :echo "F4"<CR>
+map! <F5> :echo "F5"<CR>
+map! <F6> :echo "F6"<CR>
+map! <F7> :echo "F7"<CR>
+map! <F8> :echo "F8"<CR>
+map! <F9> :echo "F9"<CR>
+map! <F10> :echo "F10"<CR>
+map! <F11> :echo "F11"<CR>
+map! <F12> :echo "F12"<CR>
+
View
3 vimrc
@@ -117,6 +117,9 @@ set timeoutlen=3000
" and 150 ms ==> 80 words per minute.
set ttimeoutlen=150
+" Configure special terminal keys.
+runtime termsupport.vim
+
" Disallow octal numbers for increment/decrement (CTRL-A/CTRL-X).
set nrformats-=octal

0 comments on commit bb61dc9

Please sign in to comment.
Something went wrong with that request. Please try again.