sponsor Vim development Vim logo Vim Book Ad

fixkey : Use non-ASCII keys in console Vim

 script karma  Rating 75/21, Downloaded by 5535  Comments, bugs, improvements  Vim wiki

created by
Michael Henry
 
script type
utility
 
description
Fixkey helps Vim use the non-ASCII keys of a terminal emulator, permitting
mapping of several classes of characters, including:

- Alt-lowercase letters (<M-a> - <M-z>).
- Alt-uppercase letters (<M-A> - <M-Z>), except <M-O> due to keycode
  ambiguity).
- Function keys with no modifiers or combinations of shift, control, and alt:
  <F1> - <F12>, <S-F1> - <S-F12>, ..., <M-C-S-F1> - <M-C-S-F12>.
  *Note* not all combination of terminal and environment send all of these.
- Arrow keys with no modifiers or combinations of shift, control, and alt:
  <Up>, <Down>, <Left>, <Right>, <S-Up>, <S-Down>, <S-Left>, <S-Right>, ...,
  <M-C-S-Up>, <M-C-S-Down>, <M-C-S-Left>, <M-C-S-Right>.
- Home and End keys with no modifiers or combinations of shift, control, and
  alt: <Home>, <End>, <S-Home>, <S-End>, ..., <M-C-S-Home>, <M-C-S-End>.
- <S-Enter> (few terminals).
- <M-Enter> (not all terminals).

Now, console Vim users can map keys like Gvim users, e.g.::

  " Map Alt-q to re-wrap a paragraph.
  :nnoremap <M-q> gqap

See documentation in doc/fixkey.txt for installation instructions and
terminal setup.

Developed by Michael Henry (vim at drmikehenry.com).

Distributed under Vim's license.

Git repository:   https://github.com/drmikehenry/vim-fixkey
 
install details
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
fixkey-0.3.15.zip 0.3.15 2023-04-29 7.0 Michael Henry - Fix regression in version 0.3.14 for terminals that lack |TermResponse|.
  Now, in addition to |TermResponse|, Fixkey watches for the |VimEnter|
  autocmd to ensure Fixkey setup will always be invoked.  Notably tmux, PuTTY,
  and Linux console do not trigger |TermResponse| autocmd events.
fixkey-0.3.14.zip 0.3.14 2023-04-01 7.0 Michael Henry - Add `g:Fixkey_useTimestamps` to produce system calls visible to `strace` for
  timing measurements.

- Change `g:Fixkey_setupDelay` to be measured from reception of the
  |TermResponse| autocmd instead of the start of Fixkey initialization.  This
  removes some variability in startup times and makes the choice of delay
  value easier.  The default delay is now 400 ms.  The previous default of 10
  ms was guesswork based on user feedback showing that delaying even 0 ms was
  sufficient; however, measurements provided by `g:Fixkey_useTimestamps` show
  that the delays actually provided by Vim's timer mechanism were
  substantially longer than what was requested, because timers may be
  postponed while Vim is busy with various startup tasks.  Waiting until
  |TermResponse| ensures that Vim has actually received the initial terminal
  response.  Additional delay is needed to ensure Vim receives and processes
  any responses to Vim's subsequent terminal queries.

  This additional delay works around problems with newer Vim and
  gnome-terminal.  The sequence `ESC P` is found in gnome-terminal's response
  to some Vim query.  If Fixkey setup occurs before this response is received,
  Vim misinterprets the `ESC P` as a keypress (Alt+P), corrupting the
  processing of the response and causing the user's first keypress to be
  swallowed.
fixkey-0.3.13.zip 0.3.13 2021-02-19 7.0 Michael Henry - Add support for Alt-shifted-numbers (<M-)>, <M-!>, ..., <M-(>).

- Document that <M-M> doesn't work with PuTTY for some reason.

- Avoid overriding a non-empty 'ttymouse' setting for tmux (thanks to Kevin MacMartin).

- Allow setting g:Fixkey_termType in vimrc to override Fixkey's terminal detection algorithm.
fixkey-0.3.12.zip 0.3.12 2021-02-19 7.0 Michael Henry - Extend detection of TERM=linux to include TERM=linux-16color and similar (thanks to Andy Weidenbaum).
fixkey-0.3.11.zip 0.3.11 2019-08-25 7.0 Michael Henry - Delay Fixkey setup at startup to avoid interfering with Vim's terminal
  negotiations.  This works around issues with newer Xterm versions (see
  https://github.com/drmikehenry/vim-fixkey/issues/11).  Startup delay is
  controlled via |g:Fixkey_setupDelay|.

- Silently skip Fixkey setup when running with Neovim.  Fixkey's features
  are not required on Neovim, as that editor already supports mapping
  Alt-keys natively.  As a convenience to users that share configuration
  files between Vim and Neovim, Fixkey skips its initialization when Neovim
  is detected.
fixkey-0.3.10.zip 0.3.10 2019-03-23 7.0 Michael Henry Support Alt-numbers (<M-0> - <M-9>), thanks to Ralf Vogler.
fixkey-0.3.9.zip 0.3.9 2018-07-26 7.0 Michael Henry Clarify documentation about the need to configure Konsole.  This is a documentation-only change.
fixkey-0.3.8.zip 0.3.8 2016-10-05 7.0 Michael Henry Work around TERM=tmux issue with mis-detected mouse settings that interfere with proper operation of <Home> and <End> keys.
fixkey-0.3.7.zip 0.3.7 2016-03-13 7.0 Michael Henry Fixup function keys and navigation keys (home/end/arrows/etc.)
for xterm, konsole, and gnome-terminal.  This corrects a problem
with stock Fedora Linux vim, because Fedora patches Vim and
exchanges the definitions for <F1> through <F4> with <xF1>
through <xF4>.
fixkey-0.3.6.zip 0.3.6 2015-10-23 7.0 Michael Henry Support TERM=tmux.  Starting with version 2.1, tmux allows TERM to be "tmux" instead of just "screen".
fixkey-0.3.5.zip 0.3.5 2014-07-27 7.0 Michael Henry Add support for \"TERM=screen-it\" and similar (thanks to Kevin MacMartin) (updated for minor typo in documentation).
fixkey-0.3.3.zip 0.3.3 2014-05-17 7.0 Michael Henry Add support for overlooked PuTTY-SCO keys <F1> to <F12>.
fixkey-0.3.2.zip 0.3.2 2013-10-03 7.0 Michael Henry Documentation reorganization.
vim-fixkey-0.3.1.zip 0.3.1 2013-09-23 7.0 Michael Henry Restore cpoptions correctly.
vim-fixkey-0.3.0.zip 0.3.0 2013-08-25 7.0 Michael Henry Add support for more modifier keys.  Now all combinations of Shift, Control, and Meta work with function keys, arrows, and home/end (on supported terminals).
vim-fixkey-0.2.3.zip 0.2.3 2013-08-20 7.0 Michael Henry Add support for -bce and -s subvariants of screen (e.g., TERM=screen-256color-bce-s will now work).
vim-fixkey-0.2.2.zip 0.2.2 2013-08-18 7.0 Michael Henry Add support for <M-Enter>, <S-Enter> for some terminals
vim-fixkey-0.2.1.zip 0.2.1 2013-08-15 7.0 Michael Henry Initial upload
ip used for rating: 3.17.28.48

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github