Where to put .tmLanguage in sublime text 3? - ruby

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.

Related

Why doesn't .gitignore.txt file show it's name in windows10?

Recently I scaffolded a project with webapp generator. It created two files .gitignore and .gitattributes. Both show a file extention of type Text Document But when I press F12 to edit any one's name then it has empty name. Here is the snapshot:
My question is why don't window show the name as .gitignore?
There is nothing special with those files. This visual guide may help you.
Also in Windows 10 you may simply try this option in View Tab of Folder Explorer:
After looking and reading closer, it seems that the "problem" is that with the default settings of Explorer "known" file-name extensions (like e.g. .txt) are just not shown.
So if you name a file .txt (full file-name) then it will show up as empty and with no name.
Dot-files are not having any "extension" to their file-name. The full file-name of e.g. the Git ignore file is .gitignore.
It comes from the Unix world where file-names doesn't have to follow the DOS and Windows name.ext scheme, and means that the file is hidden.
Windows since long allows arbitrary file-names as well, but in a name.ext scheme such files doesn't have a "name" only an extension.
Windows interprets .gitignore as an empty file name with the extension "gitignore", and thus shows an empty name be default. To properly see its name, open the folder's properties and check the "Show All File Extensions" option.
I don't have an answer, but I have a preference. I'd prefer not to show all extensions just to be able to see my .gitignore files in Windows10 file explorer.
I'm hoping to extend OP's question by showing I DO SEE .babelrc and .eslintrc, and w/o seeing all file extension setting being set to "on".
It seems, on my own system, that the associations for BABELRC and ESLINT(RC|IGNORE) are, maybe, set automatically by VSCode? In any case, why can I see those "." files, while the in.json is showing with hidden extension, but I can't see .gitignore?

How do I edit snippets in Sublime Text 3?

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.

Sublime Text: Switching files in different folders

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.

How do I save and load all files in a sublime text session as a 'project'?

I've read that you can save a ' project ' but apparently I'm doing it wrong.
What I've done is...
Create a js, html and css file and use view/layout with 3 columns so
each file has its own section of the layout.
I then went to Project / save project as / and saved the respective file in
a directory
I assumed that all files should be saved in this directory along with a file that I can click that loads them all up to reflect the workflow.
Apparently sublime has a different idea of how this should work and I do not understand it.
Essentially, there are two parts to a Sublime project - a .sublime-project file, and a .sublime-workspace file. Please see both the "unofficial" docs and the official website for information regarding projects, and the setup of .sublime-project files. These files are JSON-formatted and contain paths to any folders contained in your project, project-specific settings, and project-specific build systems. This file can (and should) be edited to customize the project to your needs. Double-clicking this file (after associating its file type with Sublime, following the procedure of your operating system) will open the project, any open files within it, and any folders you've added to it (by selecting Project -> Add Folder to Project).
The .sublime-workspace file is also JSON-formatted, but is saved automatically by Sublime and shouldn't be edited unless you really know what you're doing, and even then you probably shouldn't edit it. It contains all sorts of meta information about the project's history in Sublime, which files were open and in what order/pane, previous contents of searches, find/replace, etc., your file history, settings for various plugins like SublimeCodeIntel, and lots more. By default it is hidden when viewing the contents of folders in the Side Bar, and when double-clicked it will try to open the project instead of opening for viewing/editing, so there are several measures in place to prevent your playing with it and potentially screwing up Sublime.
.sublime-project files can be saved wherever you want, but the folders and files contained within it are not necessarily saved in the same place - they stay wherever they were saved. It usually makes sense to save them in the project's root directory, so if you have a filesystem like myhomedir/projects/web/SweetWebsite/ containing html/, js/, and css/ subdirectories, you might want to save your project as .../SweetWebsite/SweetWebsite.sublime-project, just so you know at a glance what files/folders are probably in it. However, you could save SweetWebsite.sublime-project in myhomedir/Desktop for all Sublime cares, and it would work exactly the same way. While it is possible to have unsaved files in a project, of course it's always best to save your work early and often, so you don't lose anything.
Hopefully this helps, please let me know if you have further questions.

How do I configure TortoiseHg to open a file in the right program based on its extension?

I'm using TortoiseHg v2.2.1 with Mercurial 1.9 in WindowsXP. How do I configure TortoiseHg to view a file based on the application Windows has associated with its extension?
For example, if I have a .docx file in the repository and I'm looking at its revision history, I'd like View at revision... to open the selected revision in MS Word. Likewise for other binary file types like ppt and xls, which I can't view using the default text editor or kdiff3.
Can I leverage that Windows already knows what program to use to open certain types of files or will I have to manually configure each file type of interest within the Tortoise config files?
I've found several SVN scripts in the TortoiseHg\diff-scripts folder that look like they solve a similar problem for diffing binaries rather than simply viewing them, but those don't seem to be activated and I'm not sure what if anything I need to mod in the MergePatterns.rc or Mercurial.ini files to make this all work.
To make "View at Revision" use whatever program is associated with the file's extension, try this trick: In the "Global Settings" in the "TortoiseHg" section, enter start "" as "Visual Editor". Note the empty "". This is necessary so that start will not use the file name, which gets passed in quotes by TortoiseHg, as the window title.

Resources