Sublime Text Command Palette for playing macro - sublimetext3

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.

Related

VsCode Terminal - How to clear terminal scrollback buffer - windows 10

I have googled this but not found an answer. Everytime I do a new operation I get the results of older runs. The terminal selected is powershell.
when i clear the screen cls in command line it does clear the screen but after next command I get stale data. It's annoying. Is there a way to clear the buffer in Windows 10 OS
I'm new with VSCode, and also just recently googled for an answer because the bug really bugs me XD but haven't found an answer so I made a way myself.
P.S. I'm also new with Stack Overflow so I'm sorry in advanced if I suck at explaining and commenting. XD
P.S. I'm not really sure if it'll work with yours but you can try it because it worked for me.
Apparently, you can actually clear the terminal including the scroll buffer by doing this in order:
Use the Terminal: Clear command.
Use the cls command in the terminal.
By knowing that, we can now make a keyboard shortcut for it because we're lazy XD.
But first, we need an extension to enable multiple commands for a key because VSCode doesn't really have a support for that.
Download the multi-command extension for VSCode.
Then after that, put this in your settings.json.
"multiCommand.commands":[
{
"command": "multiCommand.clearTerminal",
"label": "Clear Terminal",
"sequence": [
"workbench.action.terminal.clear",
"workbench.action.terminal.sendSequence",
{"command": "workbench.action.terminal.sendSequence", "args": {"text": "cls \u000D"}}
]
}
]
And also this, in your keybindings.json. You can use any key for the shortcut. Ctrl+K doesn't work for no reason. But you can experiment as much as you like.
{
"key": "ctrl+shift+k",
"command": "extension.multiCommand.execute",
"args": {"command": "multiCommand.clearTerminal"},
"when": "terminalFocus"
}
The only problem is that when there are already characters in the terminal, it'll be included in the send sequence, so just press the key twice. Or can someone recommend me a solution for it cause I'm lazy. XD

Sublimetext find usages, references

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

sublime tab right-click menu to add a save all options

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

Change or disable modifier key (alt) which activates the application menubar in Sublime Text 3 Linux

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.

Sublime text - select word and copy to clipboard macro

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...

Resources