161

When using Sublime Text 2 we tend to open the side bar to navigate thru files/folders in our projects. For that we can use the hotkey ctrl+k ctrl+b (in windows).

However, once we're in the side bar, we can't use it with keyboard (arrows for instance). We have to stick using it with our own mouse...

Just a note: I installed SideBarEnhancements plugin, but I didn't find anything that could solve my problem.

Any solution you might know?

Suresh Karia
  • 17,550
  • 18
  • 67
  • 85
Santi Agüero
  • 3,143
  • 8
  • 27
  • 39
  • 2
    Ctrl + b, Ctrl + k would always do wierd things like delete lines for me. Every time I wanted to toggle the sidebar, I had to spam those two shortcuts because it never worked the first time. I eventually created a shortcut for Ctrl + Shift + o. Did anybody else have this? – Marcel Aug 18 '14 at 19:57
  • 2
    Marcel, I think you don't understand this notation - it means holding Ctrl, hitting K then hitting B, not together. If you do Ctrl + K + K, it will delete the next line – Vall3y Nov 09 '14 at 10:06

13 Answers13

294

You can type Ctrl+0 (Ctrl+Zero) to focus on the side bar.

Then you'll be able to move selection among files with arrow keys and to open the selected file hitting Enter, without touching the mouse.

Community
  • 1
  • 1
Riccardo Marotti
  • 20,218
  • 7
  • 70
  • 53
  • is there any keyboard shortcut for removing the projects from the sidebar? – depz123 Jun 19 '13 at 18:46
  • @depz123 use command pallete for this. Also you can create shortcut for this action – Vladimir Starkov Jun 20 '13 at 14:12
  • 5
    Can I invoke context menu in the sidebar? – Vladimir Starkov Jun 20 '13 at 14:19
  • 6
    Use cmd+k cmd+b in mac to open sidebar but use ctrl+0 to focus on side bar and ctrl+1 to focus on editor. cmd+1 to cmd+n can be sued navigate tabs. – nicholaschris Dec 02 '13 at 13:00
  • Super handy thanks! Quick q, any way to get back to the document after CTRL+0? – cavalcade Feb 09 '14 at 02:11
  • To get back to document, type `CTRL+1` – Riccardo Marotti Feb 09 '14 at 11:25
  • 8
    `Ctrl+1` is the shortcut for "Focus Group 1", but if you want to focus the group which was originally focused, use `Esc` instead (see the [unofficial docs](http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/file_management/file_management.html#sidebar)). For example, if group 2 is focused, and you then focus the side bar, `Esc` will return the focus to group 2. – TachyonVortex Dec 16 '14 at 12:43
  • Ctrl+0 is also the Sublime Text 3 shortcut – Shan Plourde Jan 07 '15 at 02:32
  • CTRL + 0 not working in my mac sublime 3...Is there any reason, i interchanged cmd and ctrl key in sys preferences. – Mohamed Hussain Sep 17 '15 at 11:32
  • how to expand a folder in sidebar? – sprksh Apr 27 '16 at 04:37
  • (Just in case sublime developers are reading this) `Ctrl+0` is a poor combination of keys for this purpose. We have to use both hands for the switch specially on Mac keyboard where right `Ctrl` key is absent. It would be more convenient if the switch was possible with a key combination with both keys close together. – Pranjal Mittal Jun 24 '16 at 23:49
  • Is there a command for "jump to folder containing current selection"? I think you used to be able to do this on Windows File Explorer by pressing `Left`. – PJSCopeland Nov 10 '17 at 03:21
  • How could we have figured this out without this answer? – chris Feb 16 '18 at 00:49
  • 2
    @ChrisAnderson if you open Key Bindings (Preferences menu) you can see all available shortcuts. You can see that command `focus_side_bar` is mapped to `CTRL+0` – Riccardo Marotti Feb 19 '18 at 10:29
  • Solution is good, but the implementation is a pain. **When a file is not open**, `ctrl+0` focuses the file in the sidebar under it's directory location, **as expected and allowing to navigate** via keyboard. – But **if the file was already open** `CTRL+0` selects it inside the OpenFiles-*Group1* column, rather than in the *Folders* column, **making impossible to navigate**. – Pressing `CTRL+0` a second time is even more confusing: selects the file under *Folders*; but still, it is not possible to move among sibling files or parent directory... – Anybody knows a way to solve this? – Kamafeather Jul 24 '19 at 09:59
61

Another useful shortcut: ctrl + k Together with ctrl + b will show/hide the sidebar. Make sure you hit K and B in the right order

Jessica
  • 9,379
  • 14
  • 65
  • 136
Itay k
  • 4,163
  • 4
  • 31
  • 39
46

I didn't find any other complete answers, so I pulled together information from various answers and added a bit of my own.

  • Ctrl+K, Ctrl+B: toggle the sidebar
  • Ctrl+K+B: shorted form of the above (make sure you hit K and B in the right order)
  • Ctrl+0: switch focus to the sidebar (if open)
  • Up/Down: navigate file list
  • Right: expand a directory
  • Left: collapse a directory/navigate to parent directory
  • Enter: open a file

@Santiago Agüero The part you were missing was that the sidebar needs focus before the arrow keys will work (Ctrl+0).

As far as I can know, these shortcuts all work in Sublime 3, as well as Sublime 2.

One caveat: these assume you are using the default keybindings. But you can easily customize the keybindings by opening Preferences > Key Bindings - User and copying over lines from Preferences > Key Bindings - Default, changing the keys value as needed. E.g.,

{ "keys": ["ctrl+k", "ctrl+b"], "command": "toggle_side_bar" },
{ "keys": ["ctrl+0"], "command": "focus_side_bar" },

P.S. To get the fancy-looking keyboard glyphs, use the <kbd> HTML tag. E.g., <kbd>Key</kbd> will turn into Key. (Thanks to https://meta.stackexchange.com/questions/5527) :)

Community
  • 1
  • 1
Sean the Bean
  • 5,222
  • 5
  • 38
  • 40
  • In the sidebar Ctrl + Up / Down, Lets you switch between navigating the folder and files list or (up) open files list. (Tested in Subl.3) – GDmac Feb 02 '17 at 09:03
  • Documentation of these and other file navigation shortcuts http://sublime-text-unofficial-documentation.readthedocs.io/en/latest/file_management/file_navigation.html#sidebar – anishpatel May 16 '17 at 20:41
24

Summary

Ctrl + 0 will navigate to your sidebar. By default you can navigate the folders with your arrow keys. If you prefer 'Vim' type settings, you can avoid using the arrow keys by remapping your keys to the typical Vim settings (hjkl).

  • h will minimize/open a folder
  • j will navigate down (i.e. down arrow)
  • k will navigate up (i.e. up arrow)
  • l will open up a folder
  • Enter will open the file

Key mappings

To set this up, open Preferences > Key Bindings - User and add the following:

{ "keys": ["h"], "command": "move", "args": {"by": "characters", "forward": false}, "context":
    [ {"key": "control", "operand": "sidebar_tree"} ] },
{ "keys": ["j"], "command": "move", "args": {"by": "lines", "forward": true}, "context":
    [ {"key": "control", "operand": "sidebar_tree"} ] },
{ "keys": ["k"], "command": "move", "args": {"by": "lines", "forward": false}, "context":
    [ {"key": "control", "operand": "sidebar_tree"} ] },
{ "keys": ["l"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [ {"key": "control", "operand": "sidebar_tree"} ] }
Will
  • 11,276
  • 9
  • 68
  • 76
  • Is there a way to open the file, but have the cursor remain in the sidebar (e.g., opening up multiple files to setup your working environment)? – user1164937 Jul 07 '17 at 00:22
14

Ctrl+p is also really useful for opening files without using the mouse.

If you open a folder in Sublime all the files in that folder (and files in contained folders) will show up in the search you get with Ctrl+p.

Just hit Ctrl+p and start typing parts of the filename and you'll get a list of matches.

Jonatan
  • 141
  • 1
  • 2
13

For sublime text 3 use Ctrl+K+B

Press and hold Ctrl then press and holdK and then press B

Suresh Karia
  • 17,550
  • 18
  • 67
  • 85
  • 2
    I have to press and hold Ctrl, then K and also hold it and then B to toggle the sidebar in Sublime Text 3 – T. Junghans Dec 01 '15 at 09:49
  • Please, refrain from using this notation. `Ctrl+K Ctrl+B` (Hide/Show Side Bar) is *NOT* the same as `Ctrl+K+B` (which is not even possible as a shortcut). – ratijas Oct 14 '20 at 12:29
6

For Sublime Text 2 (and also Sublime Text 3) on Windows use Ctrl+0 to focus on the side bar, and use Ctrl+1 or Esc key to focus on the editor. And if it didn't work, use those 0 and 1 keys that exist in the numeric keys row under the function keys row rather than those 0 and 1 keys that exist in the numeric keypad of the keyboard. This image may demonstrate better: http://en.wikipedia.org/wiki/File:Qwerty.svg

Amr
  • 4,809
  • 6
  • 46
  • 60
6

In Sublime Text2, press keys in following format "Ctrl+k+b" and it will work on ubuntu.

It worked on my machine (v14.04 LTS)

user2508975
  • 61
  • 1
  • 2
3

I actually had the same issue, the fact that I had to trigger the reveal in side bar and then move focus to the sidebar, alongside with the fact that if the file's folder was already unfolded the focus would move to the sidebar's top, all this made me write a new plugin to reveal the file in sidebar and then move focus to there, making it a lot easier to navigate the sidebar with keyboard arrows, give it a try =)

https://github.com/miguelgraz/FocusFileOnSidebar

Miguelgraz
  • 4,376
  • 1
  • 21
  • 16
3

Another option is to use the FileBrowser package, which gives you many more actions and can be modified to your needs.

https://packagecontrol.io/packages/FileBrowser

enter image description here

Luján Fernaud
  • 81
  • 1
  • 3
  • 5
2

Ctrl + 0 will focus on the side bar.
Ctrl + 1 will focus on the editor in the 1st window.
Ctrl + 2 will focus on the editor in the 2nd window etc.
Sandeep made a great post about improving the keyboard shortcut toggling side bar on/off.
Go to Preference->Key Binding and enter:

[
    { "keys": ["ctrl+\\"], "command": "toggle_side_bar" },
]

save it and then press "ctrl+\" to toggle the sidebar.

In Linux new keybindings are saved in ~/.config/sublime-text-3/Packages/User/'Default (Linux).sublime-keymap'.

Dig
  • 261
  • 2
  • 3
1

You have to add a folder to the Sublime Text window in order to navigate via the sidebar. Go to File -> Open Folder... and select the highest directory you want to be able to navigate.

Isidro Moran
  • 322
  • 2
  • 6
0

enter this shortcode on Preference->Key Binding

[
    { "keys": ["ctrl+\\"], "command": "toggle_side_bar" },
]

now save it press "ctrl+\\" for toggle the sidebar