sponsor Vim development Vim logo Vim Book Ad

joy : Tab becomes Esc, just like Bill Joy!

 script karma  Rating 5/4, Downloaded by 676  Comments, bugs, improvements  Vim wiki

created by
Ryan King
script type
Esc key where Bill Joy had his.

// Introduction //


    :imap <tab> <esc>
    (See: https://en.wikipedia.org/wiki/Vi#Creation )

IBM made some really odd decisions in popularizing the current keyboard, so
we're taking the power back.

The :imap above is the real heart of vim-joy: just make it so hitting tab in Insert mode gets you out into Normal mode. The only extra complexity in this script is due to the "Training Wheels" needed to get used
to not being able to hit tab normally. The <Tab>=<Esc> thing is is most surprising when:

* When on an empty line, meaning "increase indent". Use <C-t> instead.
* When in the middle of a line, and trying to line things up. I don't have an exact solution for this, other than to do the work in Normal mode (e.g. with
  <C-v> combined with << and >>)

To affect the behavior of this plugin, you can either:

   let g:joy_pure = 1

Commit to using <C-t> instead of <Tab> for indentation. At this point it
becomes identical in behavior to Insert Mode <Tab> == <Esc>.

   let g:joy_mixed = 1

To turn off the nag message, and forget about <C-t> for indent.

// Temporarily Disabling //

Sometimes you want to affect the behavior only for this session (e.g. for pair
programming with someone who isn't feeling it)

To go back to impure mode:

   :unlet g:joy_pure

To make <Tab> be default in behavior:

   :unimap <Tab>

// Thanks //

Thanks to tpope, as always!

// About //

Grab the latest version or report a bug on Github: http://github.com/rking/vim-joy
install details
If you don't have a preferred installation method, I recommend
installing pathogen.vim: https://github.com/tpope/vim-pathogen
then simply copy and paste:

    cd ~/.vim/bundle
    git clone https://github.com/rking/vim-joy.git

Once you run :Helptags you can view the manual with :help joy


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
joy.vim 1.0 2013-03-21 7.0 Ryan King Initial upload
ip used for rating:

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.