Go to File

Published

Code editors like Visual Studio Code, and IDEs like PyCharm, have keybindings to make common operations easier. One essential operation is ‘Go to File…’ which allows you to go directly to a file. Instead of searching in the file explorer menu you can go straight to the file you want to open in your project.

In Visual Studio Code the hotkey on mac is command + P.

In PyCharm the hotkey on mac is command + shift + O.

In your editor type the keybinding then search using the format: ’:<line_number>:<column_number>’.

For example, for ‘Go to File…’, type ‘improving-github-on-mobile.md:3:0’ and press Enter. The file improving-github-on-mobile.md will open, and the cursor will move to line 3 at column 0. Column 0 is the beginning of the line. Try this with a file of your own.

If this is a useful hotkey to you I recommend adopting it into your coding practice. My preferred approach is to write it on a physical sticky note that I will refer to until it is muscle memory.

Give it a try. You can also experiment with searching by not typing the entire file name. For example, to search for ‘package.json’, try typing just ‘pj’. You can omit characters, and the search will still work. Have fun with it and use your keys wisely. There are only so many keys left in life. Use them wisely and keep living.