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

I write a lot of python in my VIM, on the terminal. What do I do?

share|improve this question
1  
actually, if you need to ask these question, you should really consider using another editor or IDE to write python. For the matter, home => ^, end => $, page up = ^f, page down = ^b; note that you need to quit edit mode using Esc first, and then go in again by e.g. i or a.... – bubu Jun 24 '10 at 9:33
1  
@bubu bah! I say. I do all my coding in VIM, it is an excellent editor, even for python. – Jed Daniels Jun 24 '10 at 11:17
1  
Are you referring to the 'home' 'end' 'page up' 'page down' keys on your keyboard, or are you simply looking for the proper VIM navigation commands? – Stefan Lasiewski Jun 24 '10 at 18:09

Do the standard over-30-year-old vi shortcuts of

^f (forward == page down)
^b (back == page up)
^ (that's a shift-6 caret for start of line) and
$ (end of line)

...not work?

Or are you looking for PC-style keyboard keys for those functions? For those, use Fn + arrow keys:

Fn + down arrow == page down
Fn + up arrow == page up
Fn + left arrow == home
Fn + right arrow == end

share|improve this answer
4  
The 'Fn + arrow' key combinations don't work for me using Terminal.App and Vim. – Stefan Lasiewski Jun 24 '10 at 18:11
    
| is equivalent to HOME: they both go to the 0th column of the line, rather than to the first non-space character in it. – intuited Jul 17 '10 at 20:38
    
In mc on Lion Fn + arrows only works right for me. ^f, ^b keys loads previous\next file in current folder. Thanks – kradmiy Jun 13 '12 at 9:35
    
Thanks for this! Can I also move the cursor while in insert mode? I can do this on Windows and Linux. Is Mac OS X just as good as them? Minor correction: 0 does first position of current line, whereas ^ does first nonblank character of current line. – tommy.carstensen Apr 25 '14 at 9:50
    
This does not answer the question. To get HOME and END to work in vim and in the shell, put bind '"\e[1~":"\eOH"' and bind '"\e[4~":"\eOF"' in your $HOME/.bashrc . More Mac-friendly and Linux-friendly bash/vim customization at github.com/sudoer/dotfiles . – Alan Porter Sep 16 '15 at 15:56

Vim commands (these aren't mac specific):

end of line: $

start of line: 0

page down: ctrl+f

page up: ctrl+b

share|improve this answer

If you look in the terminal keyboard settings - you can swap the actions for page up/down and shift page up/down. That works in default vim and like you'd expect on remote boxes.

gg and G are all you need for home/end. (I did spend a while trying to make it work)

share|improve this answer

To get HOME and END to work in vim and in the shell, put bind '"\e[1~":"\eOH"' and bind '"\e[4~":"\eOF"' in your $HOME/.bashrc file.

More Mac-friendly and Linux-friendly bash/vim customization at https://github.com/sudoer/dotfiles . In the bash scripts, look for the words $OSTYPE and "darwin". There's a similar "Darwin" block in the vimrc for Mac-specific vim tweaks.

share|improve this answer

You must log in to answer this question.

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