"Home" and "End" HotKeys in Vim INSERT Mode with MacBook Pro

Go to Terminal -> Preferences -> Profiles -> Keyboard and add:

Key: ↖ Action: \033OH

Key: ↗ Action: \033OF


Vim allows you to map any key sequence to other key sequence using :map command. There are several types of this command, that can be used to create shortcuts only for some vim modes. Check out this page and/or :help map command inside vim for details.

About your questions there are two ways in vim to implement Home behaviour:

  • 0 (zero) to go to the very first column
  • ^ to go to the column with the first non-whitespace character on a given line

For End you can use $. For PageUp and PageDown you can use Ctrl+F and Ctrl+B respectively.

This keys only work in command mode, but you can remap it to use in insert mode with :imap ('i' here is for insert-mode) and Ctrl+F. For example, to map Ctrl+A to act as 0 use this command:

:imap <C-a> <C-o>0

It's a very standard vim command and must work like a charm in console vim, gvim, mvim etc.


Just one tip. By default bash runs in "emacs mode". You can change it to "vi mode". Bash uses the readline package to edit your command line, for more details read the "READLINE" section of the bash man page.

In short you can redefine a lot of the key bindings in a file called .inputrc which should live in your home folder.

readline is also used by a number of other utilities and places such as the interactive python shell.