Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use sidebar with the keyboard in Sublime Text 2 and 3?

People also ask

How do I open the sidebar in Sublime Text 3?

If you open the ST console (View menu -> Show Console) and type/paste sublime. log_commands(True) Enter and then right click in the main text area and select Reveal in Sidebar , you'll see in the console the name of the command being executed.

How do I toggle the sidebar in Sublime Text?

Press and hold ctrl/command. Then press k, then b without releasing ctrl/command.

Which is shortcut key for Toggle sidebar in sublime editor?

Using the keyboard shortcut CTRL/⌘-K, CTRL/⌘-B (in this order) will toggle the sidebar.


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.


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


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) :)


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"} ] }

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.