Sublime Forum

Code navigation within files / keybindings

#1

Hi.

I’d like to be able to navigate within a file that has many functions.
I understand that there is a way to generate a list of functions that exist within a file, and navigate quickly between them.

This sounds great.

However, the default keybinding for this is ‘CTRL-r’. I have installed emacs-style navigation in ST2, which captures that keybinding for searching backwards through a file.

So I’d like to create a new keybinding for this command.
If I go to Preferences->Keybindings-user, a file opens with this line as the sole contents:

{ “keys”: “alt+shift+v”], “command”: “validate” }

How do I edit this file, so that I can create a new keybinding for generating a list of symbols?

0 Likes

#2

Go to preferences->keybindings->default. Search for “ctrl+r”, copy that line and paste into the user keybindings. Change the ctrl+r in the user keybindings to the key combination you want to use for that command.

0 Likes

#3

I’d like to keep CTRL-r for searching backwards.
So, I’d like to bind the command to a new key combination.

How do I do this? I can now see the keybindings, but I don’t know the name of the command for listing symbols. Nor do I know if the ability to list symbols is included in st2 by default.

0 Likes

#4

You’ll know the name by searching for “ctrl+r” in the default key bindings. Then after having copy and pasted that line into your user key bindings, you know where it now says “ctrl+r”? Change that to the key combination you want for that command.

0 Likes

#5

Ok, I’ve edited and saved my keybinding user preferences.
This is what it looks like now:

{
“color_scheme”: “Packages/Color Scheme - Default/Monokai.tmTheme”,
“font_size”: 10
},

{ “keys”: “ctrl+1”], “command”: “show_overlay”, “args”: {“overlay”: “goto”, “text”: “@”} }

]

The only thing is that my new keybinding doesn’t do anything. Hitting “ctrl+1” doesn’t evoke any kind of response in a buffer with a javascript file in it.

So what should I try doing now?

0 Likes

#6

keybindings != settings

There should be a file called Settings - User (where you keep the color_scheme and font_size) and Keybindings - User, where you keep your custom keybindings. They can’t be together.

0 Likes

#7

Probably the simplest way to make sure you’re putting everything in the right place is to use the menu. Click on “Preferences”, then choose “Keybindings - User”, and make sure that that file it opens looks like this:


{ "keys": "ctrl+1"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
]

Although this file will be in your Packages/User directory, what it will actually be called depends on your OS.

The docs might help as well: docs.sublimetext.info/en/latest/ … dings.html

P.S. Stuff will make sense eventually :smile:

0 Likes