Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

(experimental!) Enables ALT key mappings in terminal vim

License

NotificationsYou must be signed in to change notification settings

vim-utils/vim-alt-mappings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This plugin isexperimental. After "playing" with it (if you want), youshould probably uninstall it due to problems it can cause to your workflow.

After creating this plugin and validating the functionality via automatedtests, 2 pretty big problematic areas were discovered:

  • it breaks macros if they use<esc> + char
  • mappings that use<esc> + char won't work

So far I don't know how to solve these issues and thus the label "experimental".

Please get in touch (via github issue) if you have an idea how to solve theabove problems.

Update: I opened anissue to TimPope in vim-rsi plugin, since he uses alt mappings there as well. It seems Timwas unaware of the problem as well.

Alt mappings in terminal Vim

Build Status

This plugin enablesAlt key mappings interminal vim.

Now you can do something like this:

map <M-a> :echo "You just pressed Alt-a!"<CR>map <M-X> :echo "Works with uppercase letters."<CR>map <M-5> :echo "Numbers are supported too"<CR>map <M-$> :echo "as well as characters..."<CR>map <M-?> :echo "and more characters..."<CR>map <M-~> :echo "and more..."<CR>

Alt behaves as just another modifier key (can't get enough of those, right?)

Use cases

For example, when having soft-wrapped text in your buffer, to move betweenlines you can usegj andgk ("g" stands for graphical). When you use ita lot, you may realize that it quickly becomes tedious to have to prepend "g"every time. Drew Neil in his vimcast"Soft wrapping text"suggests mapping the "Command" key (D) to graphical keystrokes:

map<D-j>gjmap<D-k>gk

However, in Terminal vim this is not an option, because the "Command" key isused by the OS, and can't be used for mappings. Furthermore, PC users don'tevenhave a "Command" key. "Alt" mappings to the rescue!

map<M-j>gjmap<M-k>gk

Installation

Use your favorite plugin manager.

  • Pathogen
    • justgit clone https://github.com/vim-utils/vim-alt-mappings.git ~/.vim/bundle/vim-alt-mappings
  • Vundle
    • addBundle 'vim-utils/vim-alt-mappings' to .vimrc
    • then run:BundleInstall
  • NeoBundle
    • addNeoBundle 'vim-utils/vim-alt-mappings' to .vimrc
    • then run:NeoBundleInstall
  • vim-plug
    • addPlug 'vim-utils/vim-alt-mappings' to .vimrc
    • then run:PlugInstall

Terminal related setup

  • OS X Terminal.app: check "Use option as meta key"
    OS X Terminal.app setting

  • OS X iTerm2, no setup needed

  • other?

Limitations

Mappings for the following keys are (currently?) not possible:

  • Alt-O (that'sAlt big o)
    if this one is set, movements arrow keys produce funny characters in insert andcommand line mode.
  • Alt->,Alt-[ - couldn't find a way to make these work
  • Alt-space - when set up, messes up all other mappings

There are more than 90Alt key mappings available, so hopefully you won'tmiss the above 4 that are not (yet?) possible.

Selectively enable Alt mappings

If you'reaware of the issues thatAltmappings can do, and still wanna usesome of them selectively, here's how youcan do that.

  • you donot need to have this plugin installed

  • choose a character you're sure won't cause you problems in macros ormappings, for examplex. It's unlikely you'll ever have<Esc>x in yourmacros or mappings.

  • enable<M-x> mapping by putting the following in.vimrc

    set <M-x>=\<Esc>x

  • map<M-x> to something useful and use it!

    map <M-x> :echo "really useful"<cr>

Tests

This plugin uses the excellentvader.vimVimscript testing framework.To run the tests locally:

  • installvader.vim plugin
  • in this project's root directory run$ test/run

Thanks

@tpope for hisrsi.vim plugin, which was aninspiration for this one.

About

(experimental!) Enables ALT key mappings in terminal vim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp