How to use sidebar with the keyboard in Sublime Text 2 and 3?
Sublimetext2Keyboard ShortcutsSublimetext3SublimetextText EditorSublimetext2 Problem Overview
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?
Sublimetext2 Solutions
Solution 1 - Sublimetext2
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.
Solution 2 - Sublimetext2
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
Solution 3 - Sublimetext2
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) :)
Solution 4 - Sublimetext2
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"} ] }
Solution 5 - Sublimetext2
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.
Solution 6 - Sublimetext2
For sublime text 3 use Ctrl+K+B
Press and hold Ctrl then press and holdK and then press B
Solution 7 - Sublimetext2
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
Solution 8 - Sublimetext2
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)
Solution 9 - Sublimetext2
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 =)
Solution 10 - Sublimetext2
Another option is to use the FileBrowser package, which gives you many more actions and can be modified to your needs.
Solution 11 - Sublimetext2
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.
Solution 12 - Sublimetext2
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'.
Solution 13 - Sublimetext2
enter this shortcode on Preference->Key Binding
[ { "keys": ["ctrl+\\"], "command": "toggle_side_bar" },
]
now save it press
"ctrl+\\"
for toggle the sidebar