191

Is there a keyboard shortcut to move to the beginning of a file? I checked IntelliJ's Keymap for Mac OS X and it doesn't list anything for navigating to the start of a file.

Adam Parkin
  • 17,891
  • 17
  • 66
  • 87
Steve Kuo
  • 61,876
  • 75
  • 195
  • 257

7 Answers7

420

command+home or fn+command+left arrow

amadib
  • 868
  • 14
  • 33
Kirby
  • 15,127
  • 10
  • 89
  • 104
  • 25
    Thanks Kirby, those of us on Mac laptops that lack the home/end keys thank you greatly. – tojofo Aug 08 '12 at 05:15
  • 21
    Thanks. Another keytip: use fn+up or down arrow to move a page up or down. – Mellson Dec 04 '12 at 07:56
  • 1
    To select a block quickly: SHIFT-FN-CMD + UP/DOWN ARROW KEYS .. this solution got me on the right path - thanks! – Gene Bo Apr 14 '15 at 19:05
  • 4
    on windows, it is by default **Ctrl + Home** to go to the beginning of a file and **Ctrl+End** for the end. **vote this comment if you are on windows!** – Gab是好人 Jul 21 '15 at 14:41
  • 3
    That's weird, why can't Command+Up work, like in literally every other text editing application? – Hakanai Oct 18 '17 at 00:28
  • For those who want to replace this shortcut search for "Move Caret to Text Start" in keymap settings – kierzniak Nov 20 '19 at 10:45
  • 2
    I am using fn+cmd+left-arrow to go to the begining od file and fn+cmd+right-arrow to go to the end of the document. I'm working MacBook Pro. Ref: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206735685/comments/206620769 – Mohammad Selim Miah Mar 24 '21 at 02:37
113

Edit the Intellij Preferences -> KeyMap -> Editor Actions entries for "Move Caret to Text Start" and "Move Caret to Text End". If you set those to Command+UpArrow and Command+DownArrow, it'll work like a normal text editor. I have no idea why that isn't the default in Intellij instead of the seemingly pointless "scroll one line" feature.

Nathan Beach
  • 2,497
  • 2
  • 24
  • 25
  • 6
    "seemingly" is a kind way to put it. – Arel Jun 10 '15 at 17:25
  • 4
    The default setting for Text Start is Command+Home which in macbook's keyboard should be Fn+Command+Left – xi.lin May 27 '16 at 03:50
  • Excellent. I was searching for a consistent behavior between my mac and my (regular/PC) external keyboard. On my mac there's no "Home" and "End" Buttons, and the external keyboard the "fn" is not located in the bottom left - so this is the solution I sought. – Erez Cohen Jul 30 '17 at 20:36
  • 4
    One gotcha point is that you'll probably want to do the same for "Move Caret to Text [Start/End] with Selection" as well, with the shift key included. – Ian Gustafson Sep 06 '17 at 19:41
21

On Mac, command+home and command+end move to the top and bottom of the file.

On a Mac laptop, there are no home or end keys. Many key combinations with option/function keys produce missing keys and do other neat things. For instance, using function+left and function+right will provide windows-style home and end behaviour while function+up and function+down will provide page up and page down behaviour. Superuser has more information.

Also, if you open the Keyboard preferences pane and look at the Input Sources tab, you will find that the displayed keyboard changes as you press modifier keys such shift, option and function. Your keyboard probably does way more than you thought.

jackrabbit
  • 5,525
  • 1
  • 27
  • 38
  • 3
    Valid, I assume, only for keyboards that have a home and end key – Kirby Mar 13 '12 at 19:39
  • 19
    Have you owned a laptop in the past ten years? If you haven't, I'd suggest getting one, it's easier than carrying the aluminum tower around. – shanusmagnus Jan 26 '13 at 03:26
  • 2
    The tone of this answer is pretty condescending. The laptop shortcuts could have been explained in a more neutral way. – ryanbrainard Oct 17 '17 at 04:35
  • @ryanbrainard That's mainly because I get annoyed with the low amount of research that people seem to put in. Even the [wikipedia article on the Home Key](https://en.wikipedia.org/wiki/Home_key#Mac_OS_X) provides this info. Anyway, I reworded the section. – jackrabbit Oct 17 '17 at 06:36
8

The accepted answer is not correct. To move to the beginning/end of a file, use ctrl+home/ctrl+end on Windows/Unix or command-home and command-end on the Mac, as @jackrabbit suggested.

ctrl+pageup (Move Caret to Page Top) moves the caret to the top of the viewable portion of the file (page, viewport). It also does not move the caret to the first column, it tries to stay in the same column that it was previously

Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217
5

Just as an addition for clarity

For Windows,

Ctrl + Home => Top

Ctrl + End => Bottom

Ctrl + PgUp => Page Up

Ctrl + PgDn => Page Down

Supun Wijerathne
  • 11,964
  • 10
  • 61
  • 87
3

Search the Keymap preference settings, and set your own key combination for "Move Caret to Text Start" and "Move Caret to Text End". This has the behavior the OP intends, where the caret is moved to the very top of the text in file, and the very end. :D

I am using IntelliJ 12, and LOVING IT!

0

You're looking for:

Page Up => fn + up

Page Down => fn + down
Artur Müller Romanov
  • 4,417
  • 10
  • 73
  • 132