I am using sublime text 3 autocompletion for JavaScript.
For if-statement, it added a semicolon at the end.
if (true) {};
Using JSHint, it gives me an error for most of my code written.
I would like to ask how to customise this autocompletion as my preference?
Open the Sublime Text Folder by going to Preferences → Browse Packages.
Then find the folder called JavaScript
Then open if.sublime-snippet and delete the semi-colon so your snippet now looks like this:
<snippet>
<content><![CDATA[if (${1:true}) {${0:$TM_SELECTED_TEXT}}]]></content>
<tabTrigger>if</tabTrigger>
<scope>source.js</scope>
<description>if</description>
</snippet>
Since #wesbos answer did not do the trick for me here is what I found out.
Sublime 3 does not extract packages. You will find your packages (on linux) in either /opt/sublime_text/Packages/ for default packages or ~/.config/sublime-text-3/Installed Packages for packages you installed, in a zip archive with the extension .sublime-package.
To change the content of a package install the Package Resource Viewer and execute the command : Open resource browse to the file you want to change (if.sublime-snippet, I would also change the for-()-{}.sublime-snippet since it has the same strange semicolon in there) and edit it.
Once you save the file it will save it to ~/.config/sublime-text-3/Packages/JavaScript/if.sublime-snippet. This file then overwrites the default file in the original zip package.
As I understood it is important to know that files that you overwrite in this way will not be updated when you update packages, since they overwrite whatever is in the updated package!
Related
I've been using Prettier with my projects for a few weeks. I really like it!
I use the JetBrains WebStorm IDE, so I followed these instructions on the Prettier project site for how to set up a file watcher in WebStorm: https://prettier.io/docs/en/webstorm.html#using-file-watcher
Then, every time I save a JavaScript file, Prettier automatically runs on it and WebStorm shows me the changes as soon as the file is saved by Prettier.
I want everyone on my team to use Prettier, but not everyone uses WebStorm. Some people use editors that can't be easily configured with Prettier. So, I followed these instructions on the Prettier project site for how to set up a file watcher as an npm script in my package.json file: https://prettier.io/docs/en/watching-files.html
"scripts": {
"prettier-watch": "onchange '**/*.js' -- prettier --write {{changed}}"
}
I used the onchange package as my file watcher, as suggested in the docs, and I disabled the file watcher in WebStorm since I don't need Prettier to run twice in a row.
The problem is that, when I save a file in WebStorm, the onchange package runs Prettier correctly, but I don't see the changes in the editor, even when I switch out of and then back into the file window with my mouse cursor. When I try to make a new change, and save again, I get this "File Cache Conflict" warning message from WebStorm: "Changes have been made to in memory and on disk. Keep Memory Changes, Show difference, Load File System Changes"
If I choose "Load File System Changes", the version Prettier save successfully loads. But having to see this dialog box every time I save is quite annoying. I would prefer it if the changes were reflected in WebStorm automatically.
It seems like the only way is to use WebStorm's built-in file watcher instead, but then I don't have an easy way to set up Prettier for my coworkers without forcing them to manually install their own independent solutions.
So my question is this: How can I use a generic node.js file watcher as an npm script that makes changes to my files after saving, and have those changes automatically reloaded in WebStorm without this dialog box?
I was facing the same issue and no doubt that dialogue is really annoying and here're the steps that finally helped me resolving the issue.
Go to Webstorm/Phpstorm Settings/Preferences
Open up settings for File Watchers: /Tools/File Watchers/
Double click on your file watcher i.e. Prettier in this case
This will open a modal window for editing watcher. Uncheck Auto-save edited files to trigger the watcher
As per my understanding, unchecking this option will only run file watcher on manually saving the file and will help you getting rid of too much appearance of that modal on every single change. Please don't forget manually saving the file in that case to keep on enjoying Prettier.
Maybe you could try to fiddle with Use "safe write" setting on System settings pane in webstorm
I have installed the Sublime Text suggested packages, however nothing seems to work well for syntax highlighting, code linting and auto suggestion. Can someone suggest a complete package for Jade.
The Jade package on Package Control has 146,000 installs at the time of commenting. I'm pretty sure it works fine.
https://packagecontrol.io/packages/Jade
A highlighter using Python instead of JavaScript is also included for use with PyJade, you can either manually select Jade (Python) from the syntaxes list or give your file the extension .py.jade to select automatically (only on Sublime Text). Also included is a test.py.jade file that can be compiled with pyjade to test it.
You'll need to install Package Control first before installing any packages from there. It's really easy to do, just follow the instructions here. https://packagecontrol.io/installation (make sure you choose the correct version).
I've run into similar issues and would try a few things first:
First, if you happened to have your Jade file open when you did the install, you just need to close the file and re-open it to see package working.
If Step 1 isn't the issue, see if the package is enabled. Package Control > Enable Package > Jade. If you don't see it in the list of available options, that means it's already enabled. If it is in the list, then enable it.
If it is already enabled, first disable it with Package Control > Disable Package > Jade then re-enable it with Package Control > Enable Package > Jade.
Restart Sublime (probably not needed, but doesn't hurt).
This should get the package working for you.
So the autocomplete+ comes with Atom when you install it and is enabled by default.
When I am writing code, nothing shows up, why?
Is there any file I need to configure before it works properly?
In autocomplete-plus settings page there is option "File Blacklist":
and by default there is all files back listed "*.*"
so autocomplete works only in those files which have special addon installed
I have put "*.none" and autocomplete started to work in all files for me
For atom-typescript and any new typescript project in general, for things like autocomplete to work correctly, you must have a tsconfig.json file. atom-typescript has a command to generate you a file, when you're editing a .ts file.
Simple, just install atom-ternjs package.
Just install to your Atom Editor current plugin
I would like Visual Studio Code to autocomplete all words within the open document instead of the just the scope specific variables it finds. What should I change in the settings?
edit: code version 0.3.0 at time of question.
I just figured it out. This will use all words on the page for auto complete.
// Always include all words from the current document.
"javascript.suggest.alwaysAllWords": true,
// Complete functions with their parameter signature.
"javascript.suggest.completeFunctionCalls": true,
Even though it has been quite some time for this question, I thought I might be of help to anyone else who bumbles across the same question.
So here goes . And this is for the latest version of VS Code as of writing.
For a true intellisense, i.e. for example you intend to get all the methods related to "console" as soon as you press '.' , you can use the respective Typescript definition file.
Now I agree that this fix is targeted at node,and needs the same along with npm on your system. But still, works for all Major JavaScript work you might run across.
on Linux, for this, you'd need "npm" and install TypeScript Definition Manager (tsd) globally.
npm install -g tsd
then within your current project directory (or by changing to the project directory) , open a terminal window and add the following lines
tsd query node --action install
tsd query express --action install
then, as soon as you'll open your .js file in the current directory, you'll get proper autocomplete / intellisense for all DOM object and other possible stuff.
It worked for me, and this is the only reason I use VSCode on linux (for JavaScript at least, even though I like LightTable too)
for further information (and clarifications if I somehow couldnt manage to be clear enough) visit the following link:
Node.js applications on VS Code
Im new to to Sublime Text 3. I used to use Netbeans which had a great syntax correcting system for JavaScript and PHP. So far, Sublime has great features. Its fast and beautiful, but it does not have syntax correcting errors when I create JS files. Is it a possibility to get this working? I read a bit on "SublimeLinter" but when I installed it, it seems to not work correctly. Can anyone help?
Have you try to install SublimeLinter for Sublime Text 3?
(I don't think this package is directly available in the Package control plugin, so you have to dowload the .zip and extract it in your Sublime Text 3/Packages folder)
[Edit:]Check: "If you plan to edit files that use a JavaScript-based linter (JavaScript, CSS), your system must have a JavaScript engine installed. Mac OS X comes with a preinstalled JavaScript engine called JavaScriptCore, which is used if Node.js is not installed. On Windows, you must install the JavaScript engine Node.js, which can be downloaded from the Node.js site."
Sublime Linter 3 is the way I've found useful so far.
To use it, first you must install node.js on your system.
Then, using package manager find and install Sublime Linter and Sublime Linter-jshint, quit from Sublime Text.
Type npm install -g jshint onto your terminal, open Sublime Text.
Very Easy...well kind of ! here are the steps :
hint: before you do this remove a semicolon or something from you .js file to make sure you have an error for a file to test this with:
Follow this steps on the clip below:
https://www.youtube.com/watch?v=TVE3E9AvRag
Right click on the file and then run jshint
If you still don't see the yellow line editor then:
cd '/path/to/Sublime Text 3/Packages'
git clone https://github.com/SublimeLinter/SublimeLinter3.git SublimeLinter
you should see this errors/yellow dot on the line with error auto-magically :