Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In PyCharm, how to navigate to the top of the file?

I'm new to PyCharm and haven't been able to figure out what I'm sure is a very simple thing -- what's the key stroke to go to the top of the current file?

(Bonus question -- is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?)

like image 347
Ghopper21 Avatar asked Dec 28 '13 17:12

Ghopper21


People also ask

How do I navigate to a folder in PyCharm?

You can use the left arrow to go up a directory and right arrow to go down a directory. To see the contents of a directory, either press the down arrow or press enter. With this you can get to any place in the tree, without using the mouse.

How do I change the navigation bar in PyCharm?

Customize menus and toolbarsPress Ctrl+Alt+S to open the IDE settings and select Appearance & Behavior | Menus and Toolbars. In the list of available menus and toolbars, expand the node you want to customize and select the desired item. to add an action or a separator under the selected item.


2 Answers

You navigate to the top of the file using Ctrl+Home. It moves cursor too. So does navigating via Page Up and Page Down keys.

Ctrl+Up and Ctrl+Down move the view without moving cursor but scrolling the long file takes some time.

Additionally You can change the keymap (Settings > Keymap). There is 'Scroll to Top' in 'Editor Actions'. You can use Your own key binding for this action, by default (in PyCharm 4 and later) it is not set.

like image 156
Martin Avatar answered Nov 10 '22 08:11

Martin


Another way is to navigate to the first line using goto line: Ctrl-G and then 1. But this will move the cursor to the first line.

A small disadvantage is it is a two step process and adds a navigation step. Moving back to your previous location with CtrlAlt-< will have to be done in two steps if you do an edit.

like image 40
yahan Avatar answered Nov 10 '22 08:11

yahan