8

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

3
  • 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, 2010 at 9:33
  • 1
    @bubu bah! I say. I do all my coding in VIM, it is an excellent editor, even for python. Jun 24, 2010 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? Jun 24, 2010 at 18:09

4 Answers 4

17

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

7
  • 4
    The 'Fn + arrow' key combinations don't work for me using Terminal.App and Vim. Jun 24, 2010 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, 2010 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 Jun 13, 2012 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. Apr 25, 2014 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 . Sep 16, 2015 at 15:56
7

Vim commands (these aren't mac specific):

end of line: $

start of line: 0

page down: ctrl+f

page up: ctrl+b

2

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)

1

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.

You must log in to answer this question.

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