When do changes to Sublime Text 3 syntax files take effect? - sublimetext3

I'm writing a syntax definition for Sublime Text 3, using the new YAML fornat and not the deprecated one. I'm not seeing changes to the text I'm trying to highlight, though. When are changes to my syntax definition file applied to the files it's meant to highlight? And if I can force a definition reload, how can I do so?

Changes to .sublime-syntax files take effect as soon as they are saved - ST detects any changes made when the file is within the Packages folder structure. You can see this in the ST console (View menu -> Show Console) when saving the file:
generating syntax summary
Unfortunately, there is no timestamp on the entries, so sometimes it can help to manually enter something into the console to help visually separate the lines. i.e.
import time; time.asctime(time.localtime())
'Mon Jan 8 09:11:06 2018'
then, you know any lines that appear under that in the console happened after that time.
One caveat is that ST currently doesn't detect changes automatically when the files are in a symlinked folder: https://github.com/SublimeTextIssues/Core/issues/1154
In such cases, the only way to get ST to reload modified/new files is by restarting ST.

Related

Dymola, whitespace and version control

I opened a Modelica library in Dymola, changed one line, closed Dymola and clicked "Save all", now TortoiseSVN is showing several hundred changed files instead of just one file with the one line changed I intended to do. All these changes are either whitespace, or line breaks, introduced by Dymola it seems.
Of course I can now be careful to only commit the file I have changed (and revert the rest), but that makes committing more time-consuming and error-prone than it needs to be. Or I can just commit it all, but that makes it hard for my colleagues to review the change. Also, it feels like it is not deterministic, so a later commit might just revert parts back. I sometimes even revert all changes, then use a text editor to change just the one line. All this makes version control unnecessarily complicated.
When I look at the commits and diffs for e.g. the Modelica Standard library:
https://github.com/modelica/ModelicaStandardLibrary/commits/master
The diffs are nice and small and readable usually. Is there a trick to avoid the whitespace issue?
How I can I turn off all autoformatting by Dymola? Is there a technical reason to do it in the first place?
You can reduce (but not entirely prevent) this behavior as follows:
Increase the maximum line length, e.g. to 130
In the GUI: Options > Text Editor > Max line length
From the command line: Advanced.MaxLineLength=130
Let Dymola format your whole library one time
Open the text view of the top-level package
Mark everything with Ctrl+A
Auto-format with Ctrl+Shift+L or Right-Click > Auto-Format
Save everything with Ctrl+Shift+S
Now go through the changes. Most will be useful, but sometimes spaces are removed, which you usually like to keep (especially before import and extends statements. They are sometimes moved to the very left)
Commit the changes
From now on try to save individual models only, not packages
(When packages are saved, Dymola sometimes reformats the nested classes)
There are some things you can do to make pretty git commits for Modelica code:
Use a text editor instead of a graphical editor. You have absolute control of what you change.
Use a graphical editor that does not change whitespace. I'm not sure of other alternatives, but OpenModelica/OMEdit will preserve existing indentation as much as possible (it can also be used to minimize diffs from changes in other tools, but it works less and less well the more changes there are).
Use a formatter as a pre-commit hook (indenting all files according to some settings in the formatter; but then you can't manually change whitespace).
Hope someone on stackoverflow has more alternatives than this.

Sublime Text 3: import projects list from folder/files to OpenRecent list

I save several projects in a same folder by manual click Project -> Save Project As...
and I used to use cmd + ctrl + p to open Switch Projectlist to switch between projects
and everything's works fine.
but today, I accidentally remove my Switch Project list in by click Project -> Open Recent -> Clear Items, so my Switch Project list is empty now...
I know I could add them back through reopen ALL my projects. due to the number of projects is pretty a lot, that will be kind of annoying to add them back one by one.
I wanna know if there's a smarter way to do that for me.
maybe import all my *.sublime-project files from folder or something.
thanks
Short of manually opening every project, I don't think there is any way to do something like this directly. There isn't a command or plugin endpoint that I'm aware of that lets you open a project by name or filename, so it's not possible to create a plugin to do the work, and Sublime doesn't have the ability to pre-load the list of packages directly either.
That said, it is possible to manually update the list of recent projects, but whether or not that is more or less work than opening all of the projects is something to consider.
If you use Preferences > Browse Packages from the menu or the command palette, a file browser will open on your Packages folder. From there go up one directory level and go inside of the Local folder, where you will find a Session.sublime_session file.
Sublime saves it's state into this file when you quit it, and uses it to restore state when you start it again. Here you will find all of the saved information, such as the windows and files that were open and so on.
Changing this file will change the data that Sublime loads, so you can modify the session file to set up the data that you want. You need to make sure that you modify the file while Sublime is not running or your changes will be ignored and clobbered away. Also it's a good idea to make a backup of the file before you start in case things go pear shaped.
Down near the bottom of the file you will find a top level key named workspaces, and inside of it a recent_workspaces key:
"workspaces":
{
"recent_workspaces":
[
"/home/tmartin/local/src/OverrideAudit/OverrideAudit.sublime-workspace",
]
}
This is where the list of recent projects is stored for use in the menu and the quick switch project command. Particular things to notice are that the entries are naming sublime-workspace files, and that the paths are absolute.
NOTE: On windows, the filenames stored in the session file are in a format like /C/Users/tmartin and not c:\users\tmartin; on that platform you need to make sure that you adjust the paths accordingly. As long as there is already at least one entry in the list when you look at the session file, you can easily see how to construct the paths that you need.
Despite the name of the commands and menu items, what you're actually switching between is different workspaces. Every sublime-project is associated with a sublime-workspace file, which acts as a dedicated sublime_session file for that particular project. This mapping is one-to-many in that you can have multiple workspaces for the same project file, allowing you to reference the same paths in multiple windows but have different window layouts.
While Sublime is not running you can edit this file to add in the full paths to all of your workspace files; when you start Sublime up the list will be populated (every sublime-workspace file knows what sublime-project it is associated with).
What remains is whether or not it's quick to come up with the list of files in a way that you can easily paste them into the session file.

Unwanted text appears every time I close a bracket in VIM using VimTex

I am typesetting a latex file in VIM using the Vimtex plugin.
Every time I close a bracket, this text shows up automatically in the <++>.
For example:
\section{This is one}<++>
\section{The variable $V_L$<++> explains things}<++>
\begin{equation}
<+content+>
\label{<+label+>}
\end{equation}<++>
LaTeX compiles my text with those printed out in the pdf so I have to manually remove the every time. This behavior goes from $$ to {} to others also and even inside certain areas when using autocompletion features wit F5.
I did look add this question but it did not provide much help as to how to solve my issue.
How can I prevent the from being added to my tex files?
If they are a feature meant for something I do not understand, how do I prevent them from compiling in my pdf's?
This part of the documentation on the vim-latex (not Vimtex) repo on github
explains how the macro system works, how it's useful and solely meant for editing
NOTE: Place Holders
-------------
Almost all macros provided in Latex-Suite implement Stephen Riem's
bracketing system and Gergely Kontra's JumpFunc() for handling
place-holders. This consists of using "place-holders" to mark off
locations where the next relevant editing has to be done. As an example,
when you type EFI in |insert-mode|, you will get the following: >
\begin{figure}[<+htpb+>]
\centering
\includegraphics{<+file+>}
\caption{<+caption text+>}
\label{fig:<+label+>}
\end{figure}<++>
The text <+htpb+> will be selected and you will be left in |select-mode|
so that you can continue typing straight away. After having typed in the
placement specifier, you can press <Ctrl-J> (while still in insert-mode).
This will take you directly to the next "place-holder". i.e, <+file+> will
be visually selected with Vim in select mode again for typing in the file
aaaa. This saves on a lot of key presses.
Note: Upon testing I realized that the placeholder only appears when the bracketing is empty.

Change SublimeREPL shell colour

I use SublimeText3 and try to change the colour for SublimeREPL Shell because its all white. Is that possible? Or is it possible to use colours from system prompt like PS1='' ?. I am running on ubuntu. I haven't found a soloution.
I assume you're trying to color the prompt in the SublimeREPL shell - if you want syntax highlighting of the commands you type, just change the syntax to Shell Script (Bash). To do this permanently, open your Packages folder (Preferences -> Browse Packages...), browse to SublimeREPL/config/Shell, and open Main.sublime-menu as a JSON file. Line 26 contains the "syntax" setting; just change the value to "Packages/ShellScript/Shell-Unix-Generic.tmLanguage", save the file, and the next time you start it the syntax will be applied.
However, if you're just trying to color the prompt, you'll have much more work to do. First, you'll have to create a custom .tmLanguage syntax definition file creating scopes for the various parts of the prompt you want to highlight, then you'll need to alter your color scheme's .tmTheme file to actually style the scopes. (If you're using the ST3 dev builds and have Build 3084 or newer, you can also use the new YAML-based .sublime-syntax format instead of the XML-based .tmLanguage one.)
If you're not using a dev build, the best way to write syntax definitions is to use the wonderful PackageDev package. I maintain an alternate - and better :) - syntax definition for Python and I much prefer using PackageDev's .YAML-tmLanguage format, which as you can tell is also based on YAML, but was around long before the new "official" .sublime-syntax format, and of course they're incompatible. However, it is quite easy to convert from YAML-tmL to tmL to sub-syn and back again, so it's no big deal.
However, as I was saying, the contents of your syntax definition will vary depending on the exact structure of your prompt, and what you want to do with it. For the following examples, I'm assuming you have the default Ubuntu user#hostname:/present/working/directory$ prompt. To create a new syntax definition, after installing PackageDev, select Tools -> Packages -> Package Development -> New Syntax Definition and you'll get the following:
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Syntax Name
scopeName: source.syntax_name
fileTypes: []
uuid: 7e1549b3-fb0b-44fc-a153-78a7fc2157c2
patterns:
-
...
The first line is required, don't mess with it. You can make name whatever you want. scopeName is obviously the identifier for the base scope, perhaps something like source.shell.prompt. fileTypes can be left blank, and the uuid left alone as well.
If you want to get a feel for how these files are supposed to work, feel free to check out PythonImproved.YAML-tmLanguage on Github, and also make use of the Sublime Text Unofficial Documentation page on the subject as well as the reference. There's also some info in PackageDev's README.
I'll let you develop the rest of the regexes, but here's one for matching the username to get you started:
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Shell Prompt
scopeName: source.shell.prompt
fileTypes: []
uuid: 7e1549b3-fb0b-44fc-a153-78a7fc2157c2
patterns:
- name: meta.username.prompt
match: ^([A-Za-z_][A-Za-z0-9_-]{0,31})(?=#)
...
You can see it working here.
Once your .YAML-tmLanguage is complete, save the file, open the command palette, and select PackageDev: Convert (YAML, JSON, PList) to.... This will build the .tmLanguage file and put it in the same directory as the .YAML-tmLanguage file. If it's not already under the Packages directory tree, copy it to your Packages/User directory, then modify the Main.sublime-menu file as described in the first paragraph. Finally, open your color scheme's .tmTheme file and edit it to add the scopes defined in your new syntax. Save it, restart Sublime for good measure, and you should be all set!

Disable split window automatically showing input files (Vim)

In Vim, if you input Latex files vie the \input command, Vim opens up a split window displaying the included files.
This is a pretty cool feature, but after a while it gets really irritating b/c if one opens up a horizontal split that means that there are now 3 (or possibly 4) split windows: 2 that you desire and 2 more telling you what files are included for those 2 files.
you can close the window manually, but then upon saving the file it reappears again. How can I disable this for include statements only?
EDIT: I do not want to remove the split entirely. It does sometimes provide useful information. For example, if I type "see figure \ref{foo_bar}" it will warn me that I should instead use "see figure~\ref{foo_bar}". But that will go away after I fix the problem and save it. With \input statements, however, the split window never does.

Resources