If I change the document type from "Plain Text" to other scope it works, but there is no scope limit for the snippet.
I tried "Sublime Text 3 snippet not working in plain text file with no extension" but had no luck.
In syntax-specific ("plain text") user settings I added this:
"extensions":
[
"txt", ""
],
When you create a snippet without specifying any scope it will be active for every file type:
<snippet>
<content><![CDATA[
Hello, ${1:this} is a Sublime Text ${2:snippet} for all scopes.
]]></content>
<tabTrigger>hello_all_scopes</tabTrigger>
</snippet>
To make the snippet visible as a popup on auto completion add the scope to the user preferences:
{
"auto_complete_selector": "text"
}
Note that the key auto_complete_selector has a default setting that is overridden by the user key. You'll most likely want to add the default settings in your custom configuration. Scope selection can be further refined or other scopes added to the list, according to your requirements.
Related
My application has workflow that defines all of the content needed to sign a document on the DocuSign platform aside from signatures. I'm using a parameter in my text tabs to ensure that values can only be edited within my application and workflow:
tabs: {
textTabs: [
{
name: 'Name',
tabLabel: '\\*Label',
value: 'foo',
locked: true
}
]
}
When the value of the tab has no content provided, it becomes an editable field on the platform during signing; is there a way to prohibit modification of a tab entirely? It is my preference that only signatures can be provided and the remainder of the document is left uneditable.
Some options:
If the text tab is blank, and you do not want a recipient to enter information into the tab do not include it when creating your envelope
You can specify the locked=true property. The tab itself will not be visible to a signer if it is locked=true and empty.
I'm trying to create a sublime text plugin. I successfully created it, and I'm now trying to add an item to the menu, and when it's selected, it will call the plugin. I'm having trouble inserting the menu item in the correct place, and calling the plugin once created.
Say I have the following plugin:
import sublime, sublime_plugin
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, 0, "Hello, World!")
I created a folder at
C:\Users\"userName"\AppData\Roaming\Sublime Text 3\Packages\"My Plugin"
and added the plugin file to that directory. I then added the following code in a file called Main.sublime-menu
[
{
"id": "file",
"children":
[
{"id": "save"},
{"caption": "My Plugin"},
{ "command": "myPlugin" }
]
}
]
The problem is, I get two My Plugin and myPlugin items in the menu, and it's after the exit menu. I want it to be after save. Also, when I select My Plugin, I get an error in the console:
Unable to parse command:
How can I add a menu item after the save menu item, and have the menu item call a plugin called myPlugin?
Command names in plugins are not taken from the name of the python file that they're stored in; they are derived from the name of the class that implements the command so that multiple commands can be stored in a single file.
Additionally, command names are snake cased and forced to be all lower case. If your class is not named in that style, Sublime will convert it to that style by:
Throwing away the Command text at the end (if it exists)
Convert a leading upper case character to lower case
Replacing every other upper case character with an underscore and that character's lower case equivalent.
This means that for your example above, the command name you would use is example. You can't make it be myPlugin because that has an upper case character in it. Naming the class MyPluginCommand, MyPlugin or my_plugin would create a command named my_plugin, which is as close as you can get.
Your example content for Main.sublime-menu is not following the proper data structure for the items in the children array, which is why the items appear twice. There is some unofficial documentation on the menu format that outlines the fields and structure for menu items.
The reason the items are being appended to the end of the menu is because of how menus from multiple packages are merged together. Basically some items have an id field in them that gives them a unique ID; when multiple items have the same ID, they get concatenated together in the order that the packages that they came from were loaded.
Your menu items use the id of file to indicate the file menu, and then include an id of save; since the default main menu does not contain an item with that id, your items get stuck onto the end of the menu instead.
The error you're seeing in the console is because the menu item with the caption of My Plugin does not contain a command field; instead, the menu item that follows it specifies a command and does not specify a caption. Sublime is telling you that it can't parse the command because it couldn't find one.
In order to do what you want, you want a Main.sublime-menu that looks something like this:
[
{
"id": "file",
"children":
[
{
"caption": "My Plugin",
"command": "my_plugin"
}
]
},
]
This assumes that you have renamed the class implementing the command as outlined above.
I know that sublime text categorizes the source code into different scopes. Especially used for syntax highlighting.
(You can display the current scope with Ctrl+Alt+Shift P or diverse plugins)
But can you also search for/within one scope ?
Unfortunately there is no functionality built in to ST2 or ST3 that allows searches to be confined to a particular scope. If you know Python, a plugin shouldn't be too hard to write using the functions sublime.View.find() and sublime.View.find_all(), filtering the results through sublime.View.scope_name(), although you'd need to collapse the Region returned by find() to a single point for passing to scope_name().
If you're not the plugin-writing type, you might want to check out the ScopeHunter and/or ScopeAlways plugins, available through Package Control. I bind the ScopeHunter functionality to a key combination that pops up a panel with the current scope:
[
// ScopeHunter
{ "keys": ["ctrl+alt+shift+s"], "command": "get_selection_scope" }
]
A slightly less keyboard-intensive method would be to use ScopeAlways, which displays the current scope in the status bar:
This way you can move through your Find results and immediately see what scope(s) they belong to. To set it up, once you've installed the plugin from Package Control, open Preferences -> Package Settings -> ScopeAlways -> Settings - User and add the following to have it start when Sublime starts:
{
"start_on": true
}
Save the file, restart Sublime, and enjoy all the scope goodness.
I have an application that makes use of the Application Layout Control. The UI has two tabs defined in the Title Bar section. The UI also contains a Navigator control in the sidebar that allows users to select links to open other pages. What I am having troubles with is keeping the current tab set as the active tab when users click on links in the current navigator.
The "configuration" property of the Application Layout Control is a complex type, which in turn supports all the properties that define the layout itself. One of those properties is "navigationPath". If Netflix used this control on their site, the value of that property when viewing the movie information page for Ghostbusters might look something like:
/home/genres/comedies/541018
So this property can be thought of as a way of describing the page's current location in the "site map" using *nix filepath syntax.
Each titleBarTab is also a complex type; one of its properties is "selection". This property is intended to be given a value that matches part or all of the current navigationPath for the overall layout. So, continuing the Netflix example, you might define your tabs like this:
<xe:this.titleBarTabs>
<xe:pageTreeNode
page="/genre.xsp"
label="Action"
queryString="genre=action"
selection="/home/genres/action/*" />
<xe:pageTreeNode
page="/genre.xsp"
label="Comedy"
queryString="genre=comedies"
selection="/home/genres/comedies/*" />
<xe:pageTreeNode
page="/genre.xsp"
label="Drama"
queryString="genre=dramas"
selection="/home/genres/dramas/*" />
</xe:this.titleBarTabs>
On the page for Ghostbusters, then, because navigationPath property for the layout matches the pattern defined for the selection property of the pageTreeNode with a label of "Comedy", that tab will appear selected, but the others will not.
Also perhaps worthy of note is that the layout configuration also includes a property called "defaultNavigationPath". The value of this property will be compared against the selection property of each titleBarTab if the navigationPath property has no value. So you typically want to set this to a path that would cause the first tab to appear selected.
Bruce, if I am reading this right, I ran into a similar problem a while back. Does this help at all? Setting a sessionScope variable for a TitleBar tab
Is there any way to make Resharper apply a context action at every applicable site in a file?
In particular, in order to comply with coding standards, I wish to apply 'Specify type explicitly' to every 'var' declaration across a number of files.
In general, you can't apply a context action in multiple code positions.
However, in the case of specifying type explicitly, you can use Code Cleanup to batch-apply this.
Choose "ReSharper > Tools > Clean up code"
Click "Edit Profiles"
Click "Add" to create a new cleanup profile and specify a name for it (say, "goodbye var").
In the list of profile settings, clear all check boxes to prevent unwanted code style changes.
Under C# > Use 'var' in declaration, select "Do not change" for "Replace direction", and "Always use explicit type" in the other two drop-downs.
Click "OK".
Choose "ReSharper > Tools > Clean up code" once more, choose the "goodbye var" profile, and click "Run".
Note that you can invoke code cleanup in different scopes: step 7 above implies that you're calling it in the scope of the currently opened file. However, you can choose a wider scope (folder, project, solution) in the Solution Explorer and invoke Code Cleanup from there.