Watch
1
0
Fork
You've already forked vim-rsi
0
mirror of https://github.com/tpope/vim-rsi.git synced 2026-11-17 02:23:00 +00:00
rsi.vim: Readline style insertion
  • Vim Script 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Tim Pope 45540637ea Support meta maps with modifyOtherKeys
Some terminals, including xterm and iTerm, contain support for alternate
escape sequences for meta keys presses.  For example, Meta-a, normally
encoded as "<Esc>a", is instead encoded as "<Esc>[27;3;97~", where "3"
means "meta", and "97" is the ASCII decimal representation of "a".  Our
":set" hack won't catch these; we need the native "M-" map.

The rub is that Vim internally represents meta key combos as the regular
ASCII character with the 8th bit set.  For example, since ASCII "a" is
0x61, <M-a> is 0xE1, which in UTF-8 is encoded as 0xC3 0x81.  But in
Unicode, "á" is also character U+00E1, which means any map of <M-a> will
also trigger upon typing "á".

However, if we define the map in another encoding, the key combo gets
encoded as a different sequence of bytes.  For example, in the latin1
encoding, we get the simple 1 byte sequence of 0xE1, which doesn't
conflict with "á", but does conflict with, among other characters,
U+1E05, aka "ḅ", which in UTF-8 is encoded as 0xE1 0xB8 0x85.

So what's a locale that won't give us a conflict?  If we start with the
list at `:help encoding-values` and eliminate anything 8-bit or Unicode
derived, we're left with a handful of options, most of which are flagged
as "Windows only" or "Unix only".  The Korean encoding cp949 is listed
as supporting both platforms, and encodes <M-a> as 0x80 0xFC 0x08 0x65.
This is not a valid UTF-8 sequence, even if we start mid-character, so
it should serve our needs perfectly.

Shout out to Neovim for doing what Vim should have done 15 years ago and
fixing this positively archaic quirk.
2023-04-30 10:34:44 -04:00
.github Add sponsor button 2019-11-12 20:34:44 -05:00
doc Drop C-g, which conflicts with next search result 2018-03-17 15:57:33 -04:00
plugin Support meta maps with modifyOtherKeys 2023-04-30 10:34:44 -04:00
.gitignore rsi.vim 1.0 2012-12-16 18:20:41 -05:00
README.markdown rsi.vim 1.0 2012-12-16 18:20:41 -05:00

rsi.vim

You know Readline key bindings? Of course you do, they're in your shell, your REPL, and perhaps even the GUI for your OS. They're similar to Emacs key bindings (C-a for home), but with several concessions for UNIX (C-w for delete word).

With rsi.vim, I've taken that same concession philosophy and extended it to Vim. Get the most useful of the ubiquitous key bindings without blindly overriding built-in Vim functionality.

Features

  • Readline mappings are provided in insert mode and command line mode. Normal mode is deliberately omitted.
  • Important Vim key bindings (like insert mode's C-n and C-p completion) are not overridden.
  • Meta key bindings are provided in a way that works in the terminal without the perils of remapping escape.
  • C-d, C-e, and C-f are mapped such that they perform the Readline behavior in the middle of the line and the Vim behavior at the end. (Think about it.)

Installation

If you don't have a preferred installation method, I recommend installing pathogen.vim, and then simply copy and paste:

cd ~/.vim/bundle
git clone git://github.com/tpope/vim-rsi.git

Once help tags have been generated, you can view the manual with :help rsi.

Contributing

See the contribution guidelines for pathogen.vim.

Self-Promotion

Like rsi.vim? Follow the repository on GitHub and vote for it on vim.org. And if you're feeling especially charitable, follow tpope on Twitter and GitHub.

License

Copyright © Tim Pope. Distributed under the same terms as Vim itself. See :help license.