Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In putty, which is how I primarily used VIM, I could do the following:

  • Page up/down : Using the native Page up/down key. In Mac, the alternative is Fn + Up/Down, which doesn't work in the terminal (doesn't scroll inside the vim file, but scrolls the terminal buffer)
  • Similarly, the Fn + right/left keys do not take me to start/end of line

How do I emulate this functionality in Mac OS X ?

share|improve this question

migrated from Sep 15 '11 at 12:51

This question came from our site for power users of Apple hardware and software.

It could help clarify your question if you replaced or augmented "Fn + right/left" with "Home/End", which is what those Fn combinations do. – Chris Page Sep 15 '11 at 7:38

This isn't specifically a mac question, this is really a vi question.

In navigation mode, ctrl-f scrolls down a page and ctrl-b scrolls up a page (think "F"orward and "B"ack). Ctrl-d scrolls down half a page, and ctrl-u scrolls up half a page.

^ takes you to the beginning of a line, and $ to the end. I know, I know, but there are historical reasons for that.

Here's a really good cheat-sheet on vi controls. vi is a little bit arcane, but once you internalize it, it's the quickest and slickest text editor in the world.

share|improve this answer
"This isn't specifically a mac question, this is really a vi question." It's mostly about how to set up the Mac OS X Terminal application's keymap, but it turns out that the second part of the question, about start/end of line, already has a mapping in Terminal and one possible solution is to edit vi's map to understand it. Alternatively, the Terminal keyboard map could be edited. – Chris Page Sep 17 '11 at 1:53

Terminal's default preferences map Shift-Page Up and Shift-Page Down to the character sequences that tell programs like Vim and Emacs to scroll (ESC [ 5 ~ and ESC [ 6 ~).

If you want these keys to send character sequences to the terminal without the Shift modifier, you can customize the keyboard map:

Terminal > Preferences > Settings > [profile] > Keyboard

If you do this, I recommend you invert the meaning of the Shift modifier for these keys by swapping the mappings for the shifted and unshifted keys, so that the alternative behaviors are still available. Also, see the View menu, which contains scrolling commands that use the Command modifier so they're available regardless of the terminal keyboard map.

Similarly, Shift-Home and Shift-End are mapped to move to the start/end of the current line (ESC [ H and ESC [ F). These sequences are understood by Bash, but you may have to customize Vim to understand them, or edit the mappings specifically for Vim. Vim, Emacs, and some other programs send an escape sequence to put the terminal into “Application Cursor Mode”, where the Home/End keys send ESC O H and ESC O F, but Terminal (as of 10.9) does not implement this behavior. So you may wish to change the keyboard map to send these other codes instead (Bash also understands them). (On other OSes, Home and End are used for start/end of line, so Terminal provides them with the Shift modifier for symmetry.)

Control-Left Arrow and Control-Right Arrow are also mapped to "move to start/end of line" sequences by default, though they're different from the ones mapped to Shift-Home and Shift-End. Instead, they're mapped to the Emacs- and Bash-compatible sequences ESC [ 5 D and ESC [ 5 C. Assuming these aren't in use by Vim, the simplest approach would be to customize Vim to accept these, using ~/.vimrc.

share|improve this answer

I was used to Home/End getting me to the start and end of lines in Insert mode (from use in Windows and I think Linux), which Mac doesn't support. This is particularly annoying because when I'm using vim on a remote system, I also can't easily do it. After some painful trial and error, I came up with some .vimrc lines which do the same thing, and eventually found someone else who came up with a similar solution here:


:inoremap <C-e> <C-o>$
:inoremap <C-a> <C-o>0
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .