Vim Page Down Mac



Mac

Updated for Mac OS X Mountain Lion 10.8.2.

Page Down with Fn + Down Arrow Paging down is done the same way as paging up, using the same “fn” key and the Down arrow to perform the equivalent of a page down on a Mac keyboard. Yes, this is the same on all Mac keyboards, including the Apple Wireless Keyboard, the MacBook Pro keyboard, MacBook Air, and MacBook keyboards. Vim has commands for almost every key so, when creating mappings, you must make good choices. Avoid changing the behavior of vim's most important keys/commands. Get the best orientation at:help. VIM Editor Commands. Vim is an editor to create or edit a text file. There are two modes in vim. One is the command mode and another is the insert mode. In the command mode, user can move around the file, delete text, etc. In the insert mode, user can insert text. Changing mode from one to another. PgDn Key – Move down page-wise; PgUp Key – Move up page-wise; Ctrl+d – Move half-page down; Ctrl+u – Move half-page up; Insert mode – insert a text. These vim keyboard shortcuts allows you to insert a cursor in varies position based on your needs. The Vim page down keystroke is Control f. You can remember the 'f' by thinking 'forward'. More Vim page up and page down keys I use those two Vim keystrokes most of the time, but you can use other keystrokes in Vim to move up and down, as shown here.

In order to get page up and page down to work properly under Mac OSX Terminal, as well as the home and end of line (EoL), you need to go to Preferences and then Keyboard and configure the right escape key sequences.

Vim Page Down Macbook

(Note for laptop users: you don't have the page up/down and home/EoL keys, but you can simulate them by holding the 'fn' key and pressing on an arrow key. So these configurations also apply to you.)

Page

In the Terminal Preferences, go to the Keyboard pane and watch the the keys named 'page up', 'page down', 'home' and 'end'. You will see they already exist but are configured to scroll the buffer rather than sending commands to the server you're connected to.

In order to change this, double click on each of the relevant lines and select Action: 'Send string to shell:'

You then need to enter the correct string to send to the shell. This is a multiple key sequence starting with the escape character (which is represented with it's octal code 033). Here are strings you can use for each key:

As of OSX 10.6.8, the correct fix is:

KeyRecommended Escape SequenceOther possible sequences you can try if the recommended doesn't work for you
Home033OH033[1~033[H001
End033OF033[4~033[F005
Page Up033[5~
Page Down033[6~

Vim Page Down Mac Os

You can either type these strings on your keyboard (start by presseing Esc) or you can just copy paste the strings from above.

It is worth noting that some of these are already bound to Shift-Page Up, Shift-Page Down, Shift-Home and Shift-End (which are obtained with Shift-Fn-Up/Down/Left/Right on a laptop keyboard). So if you can change your habits slightly you don't actually need to reconfigure anything.

Also note that some people (including Apple) recommend to use 033[H for Home but this doesn't actually work in vi or vim. This is why I recommend using 033OH which has worked in any shell or editor for me so far (Mac terminal, Debian terminal, vim, etc.)

Vim Page Down Macbook

If the recommended sequences don't work for you: please try the alternative suggested here. Also please let us know with which shell or editor you are trying to make them work and which escape sequences work best for you. This way we can order them in order of popularity and possibly give specific advice for specific environments to future visitors of this page. Thank you for your feedback.

Vim Page Down Mac Pro

This entry was posted by François Planque and filed under Mac stuff. Tags: howto, mac os x, terminal.