Currently, Sublime 2 displays 8 items under File > Open Recent. I was hoping to double that to 16. I've searched and haven't found anything yet, except for increasing the Open Projects list, and this isn't the correct solution since I don't utilize projects. Can anyone offer any help?
As far as I'm aware, there is no setting that controls this. However by modifying the menu contents you can extend the number of items that are shown there.
To do this, you can follow these steps:
Install PackageResourceViewer if it is not already installed
From the Command Palette, select PackageResourceViewer: Open Resource
Select the Default package
Select the Main.sublime-menu resource
This opens up the file that controls what the menu contains. Near the top you will see something similar to this:
{
"caption": "Open Recent",
"mnemonic": "R",
"children":
[
{ "command": "reopen_last_file", "caption": "Reopen Closed File" },
{ "caption": "-" },
{ "command": "open_recent_file", "args": {"index": 0 } },
{ "command": "open_recent_file", "args": {"index": 1 } },
{ "command": "open_recent_file", "args": {"index": 2 } },
{ "command": "open_recent_file", "args": {"index": 3 } },
{ "command": "open_recent_file", "args": {"index": 4 } },
{ "command": "open_recent_file", "args": {"index": 5 } },
{ "command": "open_recent_file", "args": {"index": 6 } },
{ "command": "open_recent_file", "args": {"index": 7 } },
{ "caption": "-" },
{ "command": "open_recent_folder", "args": {"index": 0 } },
{ "command": "open_recent_folder", "args": {"index": 1 } },
{ "command": "open_recent_folder", "args": {"index": 2 } },
{ "command": "open_recent_folder", "args": {"index": 3 } },
{ "command": "open_recent_folder", "args": {"index": 4 } },
{ "command": "open_recent_folder", "args": {"index": 5 } },
{ "command": "open_recent_folder", "args": {"index": 6 } },
{ "command": "open_recent_folder", "args": {"index": 7 } },
{ "caption": "-" },
{ "command": "clear_recent_files", "caption": "Clear Items" }
]
},
From here you can extend the number of recent files out to 16 by adding additional lines for open_recent_file with indexes from 8 to 15 (since the indexes are 0 based), and then save the file.
As a side note, this will work for both Sublime Text 2 and Sublime Text 3.
In Sublime Text 3 this creates a package override for Default/Main.sublime-menu, which Sublime will use instead of the shipped version of the menu. If a future version of ST3 updates the main menu in any way, you won't be told and may potentially miss other menu changes and features. You can install OverrideAudit, which will warn you if that ever happens.
This is potentially also a worry for Sublime Text 2 (although OverrideAudit is ST3 only and cannot help you here), but it is unlikely that ST2 will be updated any further so this is probably of no real consequence.
I found you don't actually need to override the main menu;
just add your own menu which will appear in the end.
Create this new file (path for me in linux, in Sublime Text 3):
~/.config/sublime-text-3/Packages/User/Main.sublime-menu
In that file put something similar to OdatNurd previous answer;
(and I copy paste the same content into the files:
Context.sublime-menu
Side Bar.sublime-menu
to have the same submenu show up there)
I just made my own submenu from my own initials "elm" and put all stuff I personally use there with various "children" subtrees.
As a bonus, it will automatically show keyboard shortcuts to the same command behind it,
so I also use it as a reminder for actions that I don't use very often and forget the keyboard shortcut of.
Caveat: after posting this I realised I this works for Sublime Text 3, while the question was for Sublime Text 2. Perhaps someone can test if this also works for Sublime Text 2?
My file looks something like this:
(also added some more ideas (beside plenty recent files) for inspiration)
[
{
"caption" : "elm",
"mnemonic": "M",
"children": [
{
"caption": "Open Recent",
"mnemonic": "R",
"children": [
{ "command": "reopen_last_file", "caption": "Reopen Closed File" },
{ "caption": "-" },
{ "command": "open_recent_file", "args": {"index": 0 } },
{ "command": "open_recent_file", "args": {"index": 1 } },
// ... etc.
{ "command": "open_recent_file", "args": {"index": 29 } },
],
},
{
"caption": "Multi Line/Caret editing",
"children": [
{
"caption": "split_selection_into_lines",
"command": "split_selection_into_lines",
},
{
"caption": "Add caret above (select_lines)",
"command": "select_lines",
"args": {"forward": false},
},
{
"caption": "Add caret below (select_lines)",
"command": "select_lines",
"args": {"forward": true},
},
]
},
{
"caption": "Bookmarks",
"children": [
{
"caption": "toggle_bookmark",
"command": "toggle_bookmark",
},
{
"caption": "prev_bookmark",
"command": "prev_bookmark",
},
{
"caption": "next_bookmark",
"command": "next_bookmark",
},
]
},
{
"caption": "paste_from_history",
"command": "paste_from_history",
},
{
"caption": "Jump to matching bracket",
"command": "move_to", "args": {"to": "brackets"},
},
// ... etc. etc.
],
},
]
Bit off topic for just more recent files, but I thought this approach might also improve other usability and maintainability aspects at the same time :)
Related
When I look at the settings.json file, the keys ctrl+shift+NUMBER are supposed to jump to a certain console profile, but they don't see, to work. Looking at it through Visual Studio Code, the error message is 'Incorrect Type. Expected "object".
Key bindings in settings.json:
"keybindings": [
{
"command": "closePane",
"keys": [
"ctrl+shift+w"
]
},
{
"command": "copy",
"keys": [
"ctrl+shift+c"
]
},
{
"command": "duplicateTab",
"keys": [
"ctrl+shift+d"
]
},
{
"command": "newTab",
"keys": [
"ctrl+shift+t"
]
},
{
"command": "newTabProfile0",
"keys": [
"ctrl+shift+1"
]
},
{
"command": "newTabProfile1",
"keys": [
"ctrl+shift+2"
]
},
{
"command": "newTabProfile2",
"keys": [
"ctrl+shift+3"
]
},
{
"command": "newTabProfile3",
"keys": [
"ctrl+shift+4"
]
},
{
"command": "newTabProfile4",
"keys": [
"ctrl+shift+5"
]
},
{
"command": "newTabProfile5",
"keys": [
"ctrl+shift+6"
]
},
{
"command": "newTabProfile6",
"keys": [
"ctrl+shift+7"
]
},
{
"command": "newTabProfile7",
"keys": [
"ctrl+shift+8"
]
},
{
"command": "newTabProfile8",
"keys": [
"ctrl+shift+9"
]
},
Is there an issue with the way my settings.json file is structured?
Thanks
You need to structure your keybindings to open a new tab using the command structure:
{ "action": "newTab", "index": 0 }
The profiles are just an array and are accessed for keybindings by their index rather than their name. So you can access the first 9 profiles to open in a new tab like this:
{ "command": { "action": "newTab", "index": 0 }, "keys": "ctrl+shift+1" },
{ "command": { "action": "newTab", "index": 1 }, "keys": "ctrl+shift+2" },
{ "command": { "action": "newTab", "index": 2 }, "keys": "ctrl+shift+3" },
{ "command": { "action": "newTab", "index": 3 }, "keys": "ctrl+shift+4" },
{ "command": { "action": "newTab", "index": 4 }, "keys": "ctrl+shift+5" },
{ "command": { "action": "newTab", "index": 5 }, "keys": "ctrl+shift+6" },
{ "command": { "action": "newTab", "index": 6 }, "keys": "ctrl+shift+7" },
{ "command": { "action": "newTab", "index": 7 }, "keys": "ctrl+shift+8" },
{ "command": { "action": "newTab", "index": 8 }, "keys": "ctrl+shift+9" }
I want to make a shortcut which can insert the current date at the 72 position of the line in VScode.
I let the Cursor go to the Pos 72 first and used an extension to get the current date.
But, the customize extension did not wait for the Cursor moving, and the date appeared at the current position.
It seems like Asynchronous happens when the macros run.
Here is my code
"addDate": [
"cursorLineEnd",
{"command": "type", "args": {"text": " "}},
"cursorLineStart",
{"command": "cursorMove", "args": {"to": "right", "by": "character", "value": 72}},
{"command": "type", "args": {"text": "AD"}},
"editor.action.trimTrailingWhitespace",
{"command": "insertDateString.insertDate"},
]
The {"command": "insertDateString.insertDate"}, did not wait the cursorMove finished and worked directly.
Is there any ways like "promise...then" or priority setting that let PG runs by sequence?
Thanks
I suggest using the macro command multi-command. It properly handles synchronous commands. So using multi-command, put this into your settings.josn:
"multiCommand.commands": [
{
"command": "multiCommand.addDate",
"sequence": [
"cursorLineEnd",
{
"command": "type",
"args": { "text": " "
}
},
"cursorLineStart",
{"command": "cursorMove", "args": {"to": "right", "by": "character", "value": 72}},
{"command": "type", "args": {"text": "AD"}},
"editor.action.trimTrailingWhitespace",
{"command": "insertDateString.insertDate"}
]
}
]
and then your keybinding looks like this:
{
"key": "alt+d", // whatever you choose
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.addDate" },
// "when": "editorTextFocus"
},
And it works as expected.
Does anyone know this shortcut? I'm looking for it online, but I can't seem to find it
To move it is CTRLSHIFT1 to move to Group 0, CTRLSHIFT2 to Group 1, and so on - that's on Linux, Windows, and OSX.
Text buffers can also be moved to their neighbouring groups:
Linux, Windows:
CTRLk + CTRLSHIFTLEFT
CTRLk + CTRLSHIFTRIGHT
OSX
SUPERk + SUPERSHIFTLEFT
SUPERk + SUPERSHIFTRIGHT
Here's the whole group section of my Default (Linux).sublime-keymap - the Windows keys are all exactly the same, while the OSX keys are the same in the top section but differ in the bottom section, below where I have placed an explanatory comment.
// The keys BELOW are for Linux, Windows, and OSX.
{ "keys": ["ctrl+1"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["ctrl+2"], "command": "focus_group", "args": { "group": 1 } },
{ "keys": ["ctrl+3"], "command": "focus_group", "args": { "group": 2 } },
{ "keys": ["ctrl+4"], "command": "focus_group", "args": { "group": 3 } },
{ "keys": ["ctrl+5"], "command": "focus_group", "args": { "group": 4 } },
{ "keys": ["ctrl+6"], "command": "focus_group", "args": { "group": 5 } },
{ "keys": ["ctrl+7"], "command": "focus_group", "args": { "group": 6 } },
{ "keys": ["ctrl+8"], "command": "focus_group", "args": { "group": 7 } },
{ "keys": ["ctrl+9"], "command": "focus_group", "args": { "group": 8 } },
{ "keys": ["ctrl+shift+1"], "command": "move_to_group", "args": { "group": 0 } },
{ "keys": ["ctrl+shift+2"], "command": "move_to_group", "args": { "group": 1 } },
{ "keys": ["ctrl+shift+3"], "command": "move_to_group", "args": { "group": 2 } },
{ "keys": ["ctrl+shift+4"], "command": "move_to_group", "args": { "group": 3 } },
{ "keys": ["ctrl+shift+5"], "command": "move_to_group", "args": { "group": 4 } },
{ "keys": ["ctrl+shift+6"], "command": "move_to_group", "args": { "group": 5 } },
{ "keys": ["ctrl+shift+7"], "command": "move_to_group", "args": { "group": 6 } },
{ "keys": ["ctrl+shift+8"], "command": "move_to_group", "args": { "group": 7 } },
{ "keys": ["ctrl+shift+9"], "command": "move_to_group", "args": { "group": 8 } },
{ "keys": ["ctrl+0"], "command": "focus_side_bar" },
// The keys BELOW are for Linux and Windows only.
//
// The OSX keys all use 'super' instead of 'ctrl'.
//
// e.g. In the top command use: ["super+k", "super+up"]
// e.g. In the bottom command use: ["super+k", "super+shift+right"]
{ "keys": ["ctrl+k", "ctrl+up"], "command": "new_pane" },
{ "keys": ["ctrl+k", "ctrl+shift+up"], "command": "new_pane", "args": {"move": false} },
{ "keys": ["ctrl+k", "ctrl+down"], "command": "close_pane" },
{ "keys": ["ctrl+k", "ctrl+left"], "command": "focus_neighboring_group", "args": {"forward": false} },
{ "keys": ["ctrl+k", "ctrl+right"], "command": "focus_neighboring_group" },
{ "keys": ["ctrl+k", "ctrl+shift+left"], "command": "move_to_neighboring_group", "args": {"forward": false} },
{ "keys": ["ctrl+k", "ctrl+shift+right"], "command": "move_to_neighboring_group" },
Hope this helps.
If you mean rearranging the tabs within the same group, there's a good plugin called MoveTab
My keybindings Sublime Text --> Preferences --> Key Bindings (User) -->
{
"keys": ["super+alt+shift+["],
"command": "move_tab",
"args": { "position": "-1" }
},
{
"keys": ["super+alt+shift+]"],
"command": "move_tab",
"args": { "position": "+1" }
}
Allows CMD+Shift+Option+[ and CMD+Shift+Option+]
If you have Package Control you can install via CMD+Shift+P --> Install Package --> MoveTab
import sublime, sublime_plugin
class DualViewMoveTo(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command('set_layout', { "cols": [0.0, 0.5, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1]] })
self.window.run_command('focus_group', { "group": 0 })
self.window.run_command('move_to_group', { "group": 1 })
There's an excellent plugin offered by Sublime Text itself called Origami, it allows you to create new panes(Columns), delete panes, move and clone views(Tabs) from pane to pane. You can easily shift tabs between a split view using this plugin. Also if you just reorder the tabs in a single pane then Sublime Text offers another good plugin called MoveTab.
Is it possible to increase the number of recent projects that appear in the Projects -> Recent Projects menu in Sublime Text 2? I have searched through the settings and I haven't found anything.
Edit this file:
~/Library/Application Support/Sublime Text 2/Packages/Default/Main.sublime-menu
At around line 715 you'll see this:
"caption": "Recent Projects",
"mnemonic": "R",
"children":
[
{ "command": "open_recent_project", "args": {"index": 0 } },
{ "command": "open_recent_project", "args": {"index": 1 } },
{ "command": "open_recent_project", "args": {"index": 2 } },
{ "command": "open_recent_project", "args": {"index": 3 } },
{ "command": "open_recent_project", "args": {"index": 4 } },
{ "command": "open_recent_project", "args": {"index": 5 } },
{ "command": "open_recent_project", "args": {"index": 6 } },
{ "command": "open_recent_project", "args": {"index": 7 } },
{ "command": "open_recent_project", "args": {"index": 8 } },
{ "command": "open_recent_project", "args": {"index": 9 } },
{ "caption": "-" },
{ "command": "clear_recent_projects", "caption": "Clear Items" }
]
Add additional lines of
{ "command": "open_recent_project", "args": {"index": n } },
I.E.
"caption": "Recent Projects",
"mnemonic": "R",
"children":
[
{ "command": "open_recent_project", "args": {"index": 0 } },
{ "command": "open_recent_project", "args": {"index": 1 } },
{ "command": "open_recent_project", "args": {"index": 2 } },
{ "command": "open_recent_project", "args": {"index": 3 } },
{ "command": "open_recent_project", "args": {"index": 4 } },
{ "command": "open_recent_project", "args": {"index": 5 } },
{ "command": "open_recent_project", "args": {"index": 6 } },
{ "command": "open_recent_project", "args": {"index": 7 } },
{ "command": "open_recent_project", "args": {"index": 8 } },
{ "command": "open_recent_project", "args": {"index": 9 } },
{ "command": "open_recent_project", "args": {"index": 10 } },
{ "caption": "-" },
{ "command": "clear_recent_projects", "caption": "Clear Items" }
]
Now you have 11 recent projects
For sublime text 3 I would recommend (based on https://stackoverflow.com/a/34512015/3061838) to add a new file Main.sublime-menu to your %APPDATA%\Sublime Text 3\Packages\User folder with the following content
[
{
"caption": "Project",
"id": "project",
"mnemonic": "P",
"children":
[
{
"caption": "Open Recent More",
"children":
[
{ "command": "open_recent_project_or_workspace", "args": {"index": 0 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 1 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 2 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 3 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 4 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 5 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 6 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 7 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 8 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 9 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 10 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 11 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 12 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 13 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 14 } },
{ "command": "open_recent_project_or_workspace", "args": {"index": 15 } },
{ "caption": "-" },
{ "command": "clear_recent_projects_and_workspaces", "caption": "Clear Items" }
]
},
]
},]
The advantage of this solution is that it will survive Sublime Text updates. The disadvantage is that you will have 2 open-recent menus.
You may choose to remove the lines with index 0-7 since they are present in the original menu.
I'm trying to map keyboard shortcuts for SublimeREPL plugin commands. Looking at SublimeREPL it looks like a menu item command is defined as:
Default.sublime-commands
{
"caption": "SublimeREPL: SBT for opened folder",
"command": "run_existing_window_command", "args":
{
"id": "repl_sbt",
"file": "config/Scala/Main.sublime-menu"
}
}
or in
Main.sublime-menu
{"command": "repl_open",
"caption": "SBT for opened folder",
"id": "repl_sbt",
"mnemonic": "b",
"args": {
"type": "subprocess",
"encoding": "utf8",
"external_id": "scala",
"cmd": {"linux": ["sbt"],
"osx": ["sbt"],
"windows": ["sbt"]},
"soft_quit": "\nexit\n",
"cwd": "$folder",
"cmd_postfix": "\n",
"extend_env": {"osx": {"EMACS": "1", "PATH": "{PATH}:/usr/local/bin"},
"linux": {"EMACS": "1", "PATH": "{PATH}:/usr/local/bin"},
"windows": {"EMACS": "1"}},
"suppress_echo": false,
"syntax": "Packages/Scala/Scala.tmLanguage"
}
}
I've tried making a keybinding in my SublimeREPL.sublime-settings to:
[{ "keys": ["super+shift+k"], "command": "run_existing_window_command", "args":
{
"id": "repl_sbt",
"file": "config/Scala/Main.sublime-menu"
}
}]
But when I try to use it the Sublime console just says:
no command for selector: noop:
Same if I map it to:
[{ "keys": ["super+shift+k"], "command": "repl_open",
"args": {
"type": "subprocess",
"encoding": "utf8",
"external_id": "scala",
"cmd": {"linux": ["sbt"],
"osx": ["sbt"],
"windows": ["sbt"]},
"soft_quit": "\nexit\n",
"cwd": "$folder",
"cmd_postfix": "\n",
"extend_env": {"osx": {"EMACS": "1", "PATH": "{PATH}:/usr/local/bin"},
"linux": {"EMACS": "1", "PATH": "{PATH}:/usr/local/bin"},
"windows": {"EMACS": "1"}},
"suppress_echo": false,
"syntax": "Packages/Scala/Scala.tmLanguage"
}
}]
Your first keybinding is correct and should work as expected. Place is in Preferences -> Key Bindings - User file.
[{ "keys": ["super+shift+k"], "command": "run_existing_window_command", "args":
{
"id": "repl_sbt",
"file": "config/Scala/Main.sublime-menu"
}
}]
based on your description, I suspect that some other command is hijacking super+shift+k.
>>> sublime.log_commands(True)
will let you see what's get called when.