In Sublime Text 3, how do I edit my pre-existing snippet files? Is there a way of doing this within ST?
At the time of writing, there doesn't seem to be a straightforward answer to this anywhere on the web.
Custom snippets are saved in a .sublime-snippet file that you create when you first save the snippet.
By default, these are placed in the "User" package. You can either browse to the file like you would any other file, or using PackageResourceViewer: Open Resource -> User -> [name of your snippet file]
For those of you that like a visual instruction here it is:
Then, you can find your snippet like this:
If someone (like me) is looking to edit a custom snippet:
open file *.sublime-snippet which exists in
[home_directory]/.config/sublime-text-3/Packages/User/
If you have another file organization:
Start to make new snippet - Tools->developer->new snippet
Try to save it. Sublime shows you the right directory with snippets
Tools -> Developer -> View package file -> search for the existing snippet.
Change and save.
Here are the steps I had to follow (figure out on my own) for anyone else who wants to edit the built-in snippets of Sublime (in my case Javascript's "fun" "function" snippet). Note: this assumes you've installed the Package "PackageResourceViewer" already:
--> PackageResourceViewer: Extract Package
Then specify which package(s) you want to extract. FWIW this process was a bit confusing for me ... somehow I managed to select everything? but I only wanted/needed "JavaScript".
Wait a second or three for Sublime to extract these (no idea what this does in background, I assume maybe unzipping/extracting loose files to your file system?)
You'll get a confirmation dialog about your successful extraction
NOW you can edit built-in snippets by --> PackageResourceViewer: Open Resource
--> Select "JavaScript" (in my case)
--> Select "/Snippets" (in my case)
--> Select your snippet (in my case it was "function-(fun).sublime-snippet" or something like that.
The file will open and you can modify/save your changes ... FINALLY!
WAY too complicated IMHO but at least it works.
Here is how to edit built-in snippets manually on macOS, in this case the JavaScript snippets. This is a way to do it without installing plugins:
Right click the Sublime Text app, select "Show Package Contents"
In the Finder, navigate to Contents -> MacOS -> Packages
Copy the JavaScript.sublime-package file to ~/Library/Application Support/Sublime Text 3/Installed Packages
Change the file name from JavaScript.sublime-package to JavaScript.zip and unzip the file
In your text editor, edit the contents of the unzipped JavaScript folder as required (e.g. delete the fun snippet from the Snippets folder)
Zip up the JavaScript folder again, rename it from JavaScript.zip to JavaScript.sublime-package and leave it in the Installed Packages folder.
Restart Sublime. Your new JavaScript package will override the built-in package.
Related
When you save a project, Sublime Text will create a .sublime-workspace file. In this file, there is an array of buffers, and for each buffer there is a color_scheme property. This is set to whatever color scheme was chosen when the buffers and workspace were created.
I recently changed my theme and color scheme in my user settings file. How can I refresh all of my project's workspaces so that way it uses my new color_scheme provided in my user preference file without needed to edit each project's workspace file one-by-one?
Expanding on the answer given by Tot you can do this for all views in all windows that are open by using a nested list comprehension (remember this is Python so we can be pretty flexible):
[ v.settings().erase("color_scheme") for views in [ w.views() for w in sublime.windows() ] for v in views ]
This way you don't have to run the command in each tab individually.
The only way I found to reset tabs to user's chosen color scheme is to enter this in the console :
view.settings().erase("color_scheme")
This will reset the color scheme of the selected tab - unfortunately you'll have to do it for each tab. But it's still quicker than closing and reopening the tab.
I only have this issue with Sublime Text 3 on Mac OS X.
Source : https://www.sublimetext.com/forum/viewtopic.php?f=3&t=19310
P.S. : If you've just updated your color scheme file, you'll sometimes have to execute this command twice. Just type the up arrow in the console to write the last command again.
Windows 10 AppData-related Solution
Please make sure that you are in a similar situation as me before trying this solution (see below). Steps:
Note the language and package that the Error loading colour scheme reports (my case was: markdown and MarkdownEditing).
Go to your AppData directory (type %AppData% in file explorer address bar).
Open directory Sublime Text 3, or whatever your version is.
Open the .sublime-settings file that matches the language from step 1.
Remove any lines that refer to the package you noted from step 1.
Remember that this file should be a properly formatted JSON file when you remove lines manually. Save this file and restart Sublime Text.
Background
I've decided to post here in case some of the python script solutions didn't work for you and your situation is similar to mine. I'm using GitHub to sync my Sublime Text AppData (Windows 10), in order to keep my workflow settings the same on multiple machines. Recently, I noticed that when I uninstalled a certain package on one of my machines, I accidentally merged some configuration files for that non-existent package on my other machine. This resulted in a persistent Error loading colour scheme, in particular for me when changing syntax to markdown (the package was MarkdownEditing for reference).
I have opened a c++ project in Sublime Text and I am working on windows environment.
I need to switch among .cpp and .h files. There is a command Alt+O which can switch these files if they are in the same folder. but my files are placed as follow:
.h in myfolder/include/subfolder/
.cpp in myfolder/src/subfolder/
The file names are same, they just differ in extensions. Right now I use Ctrl+p, but I want single command to do that.
Thanks in Advance
It might not be exactly what you want but here is a workaround to accomplish what you ask for: if you download and install the CTags plugin for Sublime, you will be able to:
Build tags with Ctrl+t, Ctrl+r
Ctrl+t, Ctrl+t will make you jump to definition (from header to source) of what is under your cursor
Ctrl+t Ctrl+b to "jump back" (to header)
[EDIT]
It seems someone has implemented a plugin to accomplish what you want (didn't test it though, note that the README says that it will look for matches outside of the current folder but only in already opened files)
FWIW, the original feature is in Packages/Default/switch_file.py (also you might want to have a look to Vim equivalent code)
Switch File Deluxe does exactly what you want. It overrides Alt+O.
I manually installed a package awhile back for ST3 that had additional syntax highlighting languages. I have since removed it, and for the files it affected selected 'Open all with current extension as..' to now be Java. However when I re-open them they still default to the old package language. If I open up the syntax highlighting menu both languages are actually highlighted. If I reselect Java it will be correct until I close and re-open any file with that extension again.
Can anyone explain how I can either force it to always stay in Java or remove the other language all together?
Go to Preferences -> Browse Packages and navigate to the User folder. There should be a file in there named OtherLanguage.sublime-settings. Delete that file, restart Sublime, and you should be all set. If that still doesn't work, look for a Java.sublime-settings file in the same directory. Delete that as well, restart, and you should be back to the default behavior. Open a file with the extension, select View -> Syntax -> Open all with current extension as... and select Java. This will create a new Packages/User/Java.sublime-settings file, so don't delete it!
I'm having trouble with Ruby syntax highlighting in combination with RegExp.
Someone suggested that I update my Ruby.tmLanguage file with some additional code.
Problem is, I can't locate this file on my computer. Inside sublime_text_3/Packages I only see .sublime-package files, which I can't properly open with sublime text; it only shows numbers.
Do I have to create this file myself, and if so, where?
Or does this work differently in sublime text 3 (as opposed to 2, which was probably the latest version when this solution got posted).
reference to additional Ruby.tmLanguage code: https://gist.github.com/elgalu/3921521
Those .sublime-package files are actually zip files in disguise. The default Ruby.tmLanguage file can be extracted from Ruby.sublime-package. Open it with some sort of archive manager. Copy and rename the extension to .zip if you have to.
Once you've made the changes in Ruby.tmLanguage, the modified file goes somewhere in your packages folder (I can't remember exactly where), which you can open from ST by going to Preferences > Browse Packages.
I have recently switched from my beloved BBEdit to TextMate because of the amazing set of features TextMate's bundles provide.
However, in BBEdit I was able to create a new file within a project window without having to save it first, while TextMate forces me to save the file before going any further. Is there any way to avoid this behaviour?
you can go from the menu with "File/New from template" this will create an Untitled file to the specified template that is not saved. However it is not in the project/project window that you currently have open. But if you think about it that is correct as if the file has not been saved TM would not know where to place it till you save it.
With Textmate 2, you can use File -> New Tab (option + command + N).
Really saving it is the only way.
To save a file in the specific directory tree:
click on the directory you want the new file to be in
press Option+Command+N
now you can Command+S
It will have that directory path.