I'm using SublimeText3 and wanted to know if there is an option (package) which can be used to
Find references within the file.
Find references within the folder.
Goto definition.
I found a command called Goto->Reference, but this does not work for the current file and seems buggy.
I also found a package called wordhighlighter which is very useful.https://github.com/SublimeText/WordHighlight. I want to use this to navigate among highlighted words. Is there any keyboard shortcut to achieve this? There is an option to expand and collapse the selection but thats about it.
For someone else who comes up with the same issue, I found the answer here
How to navigate between instances of selected text in Sublime Text 3?
{ "keys": ["alt+super+g"], "command": "find_under" },
{ "keys": ["shift+alt+super+g"], "command": "find_under_prev" },
Related
I recently upgraded the version, there is a need to transplant function, but this feature I do not know because it is installed what plug-in? So now need to manually add, I know you can use shortcut keys binding, but my shortcut keys are occupied, and if you continue to set up but it is not convenient to use.
{ "keys": ["ctrl+*+*"], "command": "save_all" }
demo
needs improvement
Find the Default.sublime-package file,
rename Default.sublime-package to a zip file and unzip.
There we find the file Tab Context.sublime-menu and Context.sublime-menu
Add {"command": "save_all", "caption": "Save All"},
The effect is as follows:
Tab Context
Context
I'm a long time VS user, and I have gotten used to doing the following in order to comment out multiple lines of code:
Ctrl+K and Ctrl+C
Likewise, uncommenting requires this:
Ctrl+K and Ctrl+U
Now I am switching to Sublime Text 3 for specific types of projects, and I would like to use the same bindings. I have transferred most bindings I commonly use, but I can't find a way to use the same "double" binding in Sublime. Is it possible?
And to be clear, of course I could un-learn the binding and use Sublime's, maybe even tweak VS to use that as well. However, I'd much rather use the one (ones?) I already know.
Go to Preferences -> Key Bindings
You will have 2 view layouts
for Default key bindings that sublime provides.
for user defined key bindings
Click on the user defined layout (right side layout) and write following code into the file to make comment using ctrl+k
[
{ "keys": ["ctrl+k"], "command": "toggle_comment", "args": { "block": false } }
]
Is it possible to play a saved macro using the command palette?
I know that it is possible to assign a keyboard shortcut to a macro but that is another thing to remember and not very feasible when you have more than a few macros.
Yes, it is possible. You need to save your macro to a file at ../sublime-text-3/Packages/User/YOUR_MACRO_NAME.sublime-macro. Then add the following code to file ../sublime-text-3/Packages/User/Default.sublime-commands:
[
{
"caption": "ADD TEXT TO BE DISPLAYED ON COMMAND PALETTE",
"command": "run_macro_file",
"args":
{
"file": "res://Packages/User/YOUR_MACRO_NAME.sublime-macro"
}
}
]
I haven't been able to run a macro from the command palette but I have found the Macroptimize package to be helpful in running my macros - one hotkey gives you a list of defined macros to choose from. Not quite what you're looking for but perhaps it will be helpful.
I am trying to use the package "Alternate VIM Navigation" in ST3 on Linux Ubuntu, but the alt+i and alt+h keybindings bring up the find and help menus rather than their movement keybindings:
{ "keys": ["alt+i"], "command": "move", "args": {"by": "lines", "forward": false}},
{ "keys": ["alt+h"], "command": "move_to", "args": {"to": "bol", "forward": true}},
I have been able to disable the alt key from displaying the application menubar using CompizConfig Settings Manager, but the alt+i still brings up the find menu (and likewise for alt+h).
I have looked in many places for an answer to this, but have found nothing that works for ST3 in Linux. Here are some related answers for OSX and Windows, and an answer in Ubuntu that suggests the CompizConfig Settings Manager:
https://askubuntu.com/questions/553687/change-or-disable-modifier-key-alt-which-activates-the-application-menubar
Change behavior of Alt key in Sublime Text 2
Stop Alt key bringing up the menu in Sublime Text 2
Any solution to this in ST3 for Linux would be much appreciated!
This worked for me:
Open Sublime's packages directory by going to Preferences > Browse Packages.
Open the User directory and create a file called Main.sublime-menu
Paste the following in:
[
{
"caption": "Help",
"mnemonic": "",
"id": "help"
}
]
Save the file and enjoy!
I found a bit of a strange workaround...
I have a sublime text package called "SubRed" which has a file "Main.sublime-menu" (it's in .config/sublime-text-3/Packages/SubRed - I manually installed the package).
To disable the menubar all I have to do is:
ctrl+shift+p view: toggle menu (which does not disable the menu by
itself for some reason),
open the Main.sublime-menu file in sublime,
save it.
Then voila, the menu bar is gone and I can finally use my Alternate Vim package key bindings without conflicting with the alt+[menubar mnemonic].
To get the menu bar back if needed, just simply do ctrl+shift+p view: toggle menu.
If anyone could suggest a better solution based on this (which doesn't involve a random 3rd party package) that would be much appreciated!
The ideal solution would be to not have to disable the menubar, but get it to work like windows where user or package defined st3 keybindings take precedence over default or system bindings. So if "alt+i" is defined by the package as "move up a line", then it no longer opens the "Find" menu, but actually (eureka!) moves up a line! But opening the "Find" menu is still possible with "alt, i" in sequence.
In Netbeans its possible to create a macro for selecting a word and copying it to clipboard
I wonder if its possible with Sublime Text 2 ?
Thanks for any help.
Edit : I understand that this is possible with a plugin. But I dont know Python, if any Python developers can create a plugin for this, it would be awesome! :)
You can easily do this with two keystrokes - CtrlD,CtrlC.
After some searching I managed to find its solution.
And the solution is a plugin.
In the menu, go to Tools -> New Plugin ->
For select the text and copy, this is the plugin content
import sublime, sublime_plugin
class SelectAndCopyCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("find_under_expand")
self.window.run_command("markSelection")
self.window.run_command("copy")
And I saved it as select_and_copy.py
For the select and paste, this is the plugin content
import sublime, sublime_plugin
class SelectAndPasteCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("find_under_expand")
self.window.run_command("markSelection")
self.window.run_command("paste")
And I saved it as select_and_paste.py
And the last thing you need to do is to bind this to a keyevent.
For this, in the menu, go to - Preferences -> Key Bindings - User
I have this content.
[
{ "keys": ["alt+`"], "command": "select_and_copy" },
{ "keys": ["alt+1"], "command": "select_and_paste" }
]
So, thats it, hope this helps for someone ! :)
You can do this using a sublime macro. Create a file named select-copy.sublime-macro in your Package folder:
[
{ "command": "find_under_expand" },
{ "command": "copy" }
]
And add the following entry to your key bindings file:
{
"keys": ["ctrl+up"],
"command": "run_macro_file",
"args": {"file": "res://Packages/User/select-copy.sublime-macro" }
},
And that's it, no plugin needed !
You can also record the macro if you don't want to dive into the config files to find the commands that you need:
Tool > Record Macro
Do some magic here.
Tool > Stop Recording Macro
Tool > Save Macro...