In Sublime Text 3, I'm using the WordCount plugin to know how long a file is, in terms of words.
However, this plugin slows down the editor when a huge text file is open. It's a file I use quite often, so this proves annoying. (The file is close to 6MB/1 million words and used on a recent MacBookPro.)
As such, I want to be able to disable and re-enable the WordCount plugin quickly and easily. I know how to do disable a plugin through Palette commands but I'm not happy with this solution.
Instead, I'd like to use a custom menu. I can create the custom menu itself (with a file named Main.sublime-menu located in /Users/*myusername*/Library/Application Support/Sublime Text 3/Packages/User/Main.sublime-menu) :
[
{
"caption": "Custom",
"id": "custom",
"children":
[
{ "command": "*somecommandhere*", "args": {}, "caption": "Toggle WordCount plugin", "checkbox": true }
]
}
]
However, I don't know which command to use to disable/re-enable a plugin. I assume this would be the same command from the console and inside of a menu file.
The following Main.sublime-menu will work:
[
{
"caption": "Custom",
"id": "custom",
"children": [
{
"caption": "Disable Package",
"id": "disable_package",
"command": "disable_package"
}
]
}
]
When selected, it opens a dropdown menu with all of the currently-active packages listed, and you can use fuzzy matching to quickly select the package you want to disable. Unfortunately, there is no way to specify which package you want to disable, as DisablePackageCommand doesn't take any arguments.
I am under exactly the same situation as you. Same big default file, same MBP, same WordCount plugin. And here is my solution.
To disable packages
Press super + , to bring up Preferences.sublime-settings, which can also be allocated at:
OSX
~Library/Application Support/Sublime Text 3/Packages/User
Windows
C:\Users\USERNAME\AppData\Roaming\Sublime Text 3\Packages\User
Linux
~/.config/sublime-text-3/Packages/User
Because the package Vintage is disabled by default, you should find these lines in your Preferences.sublime-settings.
"ignored_packages":
[
"Vintage"
],
Add "WordCount", (include the comma) before the last package(i.e. "Vintage") inside "ignored_packages".
"ignored_packages":
[
"WordCount",
"Vintage"
],
Save the file. That is it! The WordCount plugin has been disabled.
To enable packages
press super + , to bring up Preferences.sublime-settings, use supre + / to comment out the package. Like this:
"ignored_packages":
[
// "WordCount",
"Vintage"
],
Save the file. That is it! The WordCount plugin has been disabled.
To toggle packages like a pro (conclusion)
super + , to bring up preferences.
super + / to enable or disable packages.
super + s to profit.
No mouse, no plugin needed, no need to restart ST.
It is very simple and fast. I always use this method to quickly enable and disable packages in Sublime Text. Hope it help :)
Related
When attempting to setup SDL2 with VS Code in Ubuntu 20.01 LTM I get the following VS Code error:
cannot open source file "begin_code.h" (dependency of "SDL2/SDL.h")
Any tips?
Just add "/usr/include/SDL2/" to your c_cpp_properties.json like so:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/SDL2/"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu18",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
in case you don't have the "c_cpp_properties.json" file in your
folder.
Different answer than above, but I believe might be a better approach.
to create the c_cpp_properties.json on your workspace
do the following:
ctrl + shift + p (opens the command palette)
search for "C/C++: Edit Configurations (JSON)" and click on it
"c_cpp_properties.json" file will be created on your workspace
add "/usr/include/SDL2/" to your "c_cpp_properties.json" like
https://stackoverflow.com/a/64187964/8540466
reload C/C++ IntelliSense extension.
I'm assuming you already have the extension
"C/C++ IntelliSense, debugging, and code browsing"
installed on your vscode.
After these steps this problem was fixed for me.
If you, like me, don't have the c_cpp_properties.json file in your project, you can solve it by adding the following line to your settings.json (in VSCode, hit Ctrl+Shift+P and search for Open settings (JSON)):
{
// ...
"C_Cpp.default.includePath": ["/usr/include/SDL2", "${default}"],
//...
}
When a build a conda environment like this
conda create --prefix env python=3.6.5
Some absolute paths appear in some json files in the conda-meta folder. How can I avoid it? I just want to use relative paths here or I just want to hide them completely. Is there a way to achieve this? Are they mandatory? See extracted_package_dir, source or package_tarball_full_path attributes:
{
"arch": "x86_64",
"build": "py36_0",
"build_number": 0,
"channel": "https://repo.anaconda.com/pkgs/main/win-64",
"constrains": [],
"depends": [
"python >=3.6,<3.7.0a0"
],
"extracted_package_dir": "C:\\Users\\UserName\\AppData\\Local\\conda\\conda\\pkgs\\certifi-2019.3.9-py36_0",
"features": "",
"files": [
"Lib/site-packages/certifi-2019.03.09-py3.6.egg-info",
"Lib/site-packages/certifi/__init__.py",
"Lib/site-packages/certifi/__main__.py",
"Lib/site-packages/certifi/__pycache__/__init__.cpython-36.pyc",
"Lib/site-packages/certifi/__pycache__/__main__.cpython-36.pyc",
"Lib/site-packages/certifi/__pycache__/core.cpython-36.pyc",
"Lib/site-packages/certifi/cacert.pem",
"Lib/site-packages/certifi/core.py"
],
"fn": "certifi-2019.3.9-py36_0.tar.bz2",
"license": "ISC",
"link": {
"source": "C:\\Users\\UserName\\AppData\\Local\\conda\\conda\\pkgs\\certifi-2019.3.9-py36_0",
"type": 1
},
"md5": "e1faa30cf88c0cd141dfe71e70a9597a",
"name": "certifi",
"package_tarball_full_path": "C:\\Users\\UserName\\AppData\\Local\\conda\\conda\\pkgs\\certifi-2019.3.9-py36_0.tar.bz2",
"paths_data": {
"paths": [
[...]
If I remove the whole folder the environment become useless and I cannot activate it anymore in order to install, update or remove new packages.
I want to do this to encapsulate the environment in one application and I do not want to have my original absolute paths in the computer of the final user.
My Use Case
I am developing an electron app that uses a tornado server (that uses python)
Currently I am using electron-builder to add the environment to the installer and works pretty well, but one drawback is the conda-meta folder I commented above. What I do now is to remove it manually when I want to make an installer.
That will probably break conda. It's not written to treat those as relative paths. If you told us more about your use case, maybe we could help. Are you trying to redistribute an installed environment? Have you see the "constructor" or "conda-pack" projects?
Finally the best solution I found was to ignore the folder when creating the final installer with electron-builder.
So I have applied the directive extraResources to add the conda environment except the folder conda-meta. And I have added the filter "!conda-meta${/*}", the meaning is explained here
Remember that !doNotCopyMe/**/* would match the files in the doNotCopyMe directory, but not the directory itself, so the empty directory would be created. Solution — use macro ${/*}, e.g. !doNotCopyMe${/*}.
The result in the package.json file:
"extraResources": [
{
"from": "../env",
"to": "env",
"filter": [
"**/*",
"!*.pyc",
"!conda-meta${/*}"
]
}
],
For example, there is package for less LessToCss. As for Sass(or SCSS) I don't know what i should do. Ruby and sublime package Sass are installed.
You have to alter the PATH variable at the end of PATH string in the Environment Variables: Desktop - Properties - Environment Variables. It for win vista/7 users. Detail for 2000/XP here Sass compiler not working in sublime text 3
One way is to download a SASS build compiler from here: SASS Compiler
This is automatic Sublime package that simply builds your file at the place.
However since they released the new version, there seem to be multiple settings on this package - you could try to mess with that a bit and see what it can do nowdays.
Second way is to write your own Build command in Sublime. You do this by going to "Tools>Build System>New Build System..."
{
"cmd": ["sass", "--update", "$file:${project_path}/Project/Web/css/${file_base_name}.css", "--stop-on-error", "--style", "compressed", "--no-cache", "--sourcemap=none"],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/usr/local/bin:$PATH"
},
"windows":
{
"shell": "true"
}
}
Explanation: I use a folder structure as the following: Project/Web/CSS - If you have the Sublime Project FILE at the same level as Project FOLDER, then this will automatically build your Sass file (placed ANYWHERE in the project file) in your Web/CSS folder. Of course you can change this as you see fitting.
here is 100% solution, as i also using. Actually i am using in mac so, i am not sure about windows because i wouldn't try yet in windows but i think it will works in window's too.
so here is the build;
copy this from starting brackets and paste it into build and then save with any name like (Build to CSS),"
{
"cmd": ["sass", "--update", "$file:${file_path}/../css/${file_base_name}.css", "--stop-on-error", "--no-cache"],
"osx":
{
"path": "/user/local/bin:$PATH"
},
"windows":
{
"shell": true
}
}
If it's working then please comment.
Thanks
How to make Visual Studio Code (or Go Programming Language Extension) to run go fmt (or other tools/commands) on save? Even auto save?
Update:
It is working now perfectly inside VSCode, at this time; just need to add some config files inside .vscode directory (I use these).
Update 2019:
This question is old. The VSCode Go extension has all you need to develop in Go, now.
Last Update 2019
BTW It worth mentioning that right above the package declaration inside your test files appears a run package tests. If you click it, you can see your code coverage of your code. The covered and not-covered parts are highlighted in different colors.
Update 2020
And now, the Go Extension for VSCode, is under the supervision of Go Team! 🎉
Now, the feature has been implemented, you can enable format on save:
Open Settings (Ctrl + ,)
Search for editor.formatOnSave and set it to true
Your Go code will be formatted automatically on Ctrl + s
Its not possible at the moment but its being worked on https://github.com/Microsoft/vscode-go/issues/14
I'm not familiar with 'go fmt' specifically, but you can create a simple vscode extension to handle on save event and execute any arbitrary command passing the file path as an argument.
Here's a sample that just calls echo $filepath:
import * as vscode from 'vscode';
import {exec} from 'child_process';
export function activate(context: vscode.ExtensionContext) {
vscode.window.showInformationMessage('Run command on save enabled.');
var cmd = vscode.commands.registerCommand('extension.executeOnSave', () => {
var onSave = vscode.workspace.onDidSaveTextDocument((e: vscode.TextDocument) => {
// execute some child process on save
var child = exec('echo ' + e.fileName);
child.stdout.on('data', (data) => {
vscode.window.showInformationMessage(data);
});
});
context.subscriptions.push(onSave);
});
context.subscriptions.push(cmd);
}
And the package file:
{
"name": "Custom onSave",
"description": "Execute commands on save.",
"version": "0.0.1",
"publisher": "Emeraldwalk",
"engines": {
"vscode": "^0.10.1"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:extension.executeOnSave"
],
"main": "./out/src/extension",
"contributes": {
"commands": [{
"command": "extension.executeOnSave",
"title": "Execute on Save"
}]
},
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
},
"devDependencies": {
"typescript": "^1.6.2",
"vscode": "0.10.x"
}
}
The extension is enabled via cmd+shift+p then typing "Execute on Save", but it could be reconfigured to start via another command including "*" which would cause it to load any time VSCode loads.
Once the extension is enabled, the event handler will fire whenever a file is saved (NOTE: this doesn't appear to work when file is first created or on Save as...)
This is just a minor modification of a yo code scaffolded extension as outlined here: https://code.visualstudio.com/docs/extensions/example-hello-world
Update
Here's a Visual Studio Code extension I wrote for running commands on file save. https://marketplace.visualstudio.com/items/emeraldwalk.RunOnSave.
I was using CTRL+S for saving the file manually (this is habitual for me). However, I had a different binding in VS Code that would start with CTRL+S (e.g. swagger extension has a chord where pressing CTRL+S CTRL+W would generate the swagger annotation). This resulted in VS Code waiting for me to press the second chord (CTRL+W) and as such it ignored the save part altogether. I reconfigured all the keybinding chords which had CTRL+S as the first chord to a different combination. After this, pressing CTRL+S formatted my file with gofmt properly.
What I've got:
New copy of Yosemite, homebrew installation of python 2.7, Sublime Text 2 with the following packages: LaTex tools, Package Control, Rbox, and SublimeREPL. I downloaded package feedparser with Pip.
I'm new to python (and any coding beyond R) and I'm trying to set up a good workflow with Sublime Text 2. For some reason, when I try and load feedparser in the sublime REPL python window, I get "import error, no module named feedparser".
However, I can get the packaged to load from python in the terminal.
which python in terminal I get back usr/local/bin/python which is where homebrew puts python.
I have a limited understanding of this stuff, but I'm assuming its because REPL is using the old version of python that comes with OSX.
I tried changing the environment variable in the Python.sublime-build file according to this post (first answer):
Sublime Text 2: custom PATH and PYTHONPATH
Yet, it still does not work. Maybe I did it wrong? I'm not sure.
With the number of people using Sublime text and Python I know that this must get dealt with all of the time. I've lots of posts with people suggesting many different things and I'm fairly lost.
Thanks.
For Mac OSX [Racket 6.03] [Sublime Text 3]
For those interested in RACKET (DR RACKET) Repl, and are recieving an error when launching the repl "file not found".. I found out -- after spending a couple hours trying to reconfigure files -- the solution..
Open Dr Racket.
-> Help -> Configure Command Line for Racket -> click "ok" box.
-Done.
Launch the Repl in Sublime Text.
You can add a new menu item to Tools -> SublimeREPL -> Python. First, open your Packages/User directory by selecting Sublime Text 2 -> Preferences -> Browse Packages... and opening the User directory. Create a folder in User called SublimeREPL, inside that create a config directory, and inside that create a Python directory. Finally, make a new file in Sublime with JSON syntax and the following contents:
[
{
"id": "tools",
"children":
[
{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{
"caption": "Python",
"id": "Python",
"children":
[
{
"command": "repl_open",
"caption": "Python (Homebrew)",
"id": "repl_python",
"mnemonic": "p",
"args":
{
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/usr/local/bin/python", "-i", "-u"],
"cwd": "/Users/williamrudisill/Development/python",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]
}
]
}
]
}
]
Save this file as Packages/User/SublimeREPL/config/Python/Main.sublime-menu. Make sure you edit the "cwd" parameter to set the folder you'd like the interpreter to open in.
Now, if you open Tools -> SublimeREPL -> Python there will be an item called Python (Homebrew) that you can use to open an interpreter with /usr/local/bin/python.