I want to use tabs for indentation in my Javascript files. I changed the configuration as usual, but the preview doesn't seem to take my modification in account. Neither in the acutal files.
What is surprising is that the "Spaces" subtab is formatting the code the right way, but it's is the only place where it works. (See screenshots below)
Did anyone have the same issue ?
I am using IntelliJ Ultimate 2016.1
Take a look a editorconfig.org .
You will need a .editorconfig file at the root of your project. It's a markup file that works accros multiple IDE's to set some common configuration like indentation and trailing spaces. Here is an example.
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
[*.js]
indent_size = 2
From Intellij Idea 14 onwards, IDE by default detects existing indentation styles in existing files and uses them instead of your settings. You can Turn this feature off in the prefferences:
Prefferences -> Editor -> Code Style -> Detect and use existing file indents for editing
If turning off this feature does not help, make sure your project does not have .editorconfig file, which defines indentation styles as well.
Related
(There's a similar question asked >> Visual Studio - blank line at the end of each new file. But This is the complete opposite. And that doesn't answer this)
I have Visual Studio Code Version 1.19.0 on OSX.
JavaScript (ES6) linter wants me to add a new blank line at the end of each file. When I hit save after adding a new blank line myself at the end of the file, VS Code removes that automatically. My concern is that, overriding any DEFAULT User Setting won't fix that.
Anyone with a solution? Thanks in advance.
(Setting I tried overriding but failed >> "files.insertFinalNewline": true)
You can change the linter rule that enforces you to enter new line at the end
so this will work
if you use ESlint you cab use the rul eol-last and set its value to "never"
in your .eslintrc file
{
"rules": {
"eol-last" :"never"
}
}
learn more
eol-last ESlint
For those who want to get rid of the new line at the end of a file:
I had a similar issue and the solution provided by 9paradox in this post solved my problem.
When I was saving my code (Python, JSON, JS, etc...) I got always a new line inserted at the end of the file.
Solution: if, e.g. on Mac, you are editing any file in your project, then go to the root directory of your project, let's say /Users/<username>/git/<project> then search for .editorconfig in that folder, then open that file with any text editor like vi or TextEdit and make insert_final_newline = false. VS Code takes over the settings changes immediately. No restart needed.
I want to auto-indent an entire JavaScript file in WebStorm, and in my settings I have the following:
The problem is that when I use the menu Code -> Auto-Indent Lines or Code -> Reformat Code the indentation level remains at 2.
Is there a setting somewhere I am missing? I don't want to be inconsistent with the coding standards put in place.
The problem was with the .editorconfig file located in the root of the project directory. Although I can't recall receiving a warning, the settings in that file overwrote the Webstorm settings, and changing them to the desired indentations resulted in the desired result.
I am using following :
TypeScript version : 0.9.5
WebEssential version : 3.7
Visual Studio : 2012
After saving the TypeScript file, the JS file does not contains the commented code.
I am also facing some extra space issue in the JS file. After every 'if' and 'for' statement, now there is extra white-space between the 'if' and the '('. Earlier the code was generated as 'if(' now the code is generated as 'if (', becuase of thsi extra space, repository treat there is a difference in previous version of JavaScript file and the current version.
Earlier WebEssentials gave option to retain comments which is missing now - See the image below - These options are not available with WebEssentials now.
See the below image to understand spacing issue
Where can I find setting to avoid extra space and force JS file to retain the comments added in TS file?
I looked at the Tools > Options > Web Essentials > TypeScript setting and Tools > Options > Text Editor > TypeScript in visual studio but could not find anything that would help me.
I just read the extra spacing issue will be addressed in v1.0 of TypeScript
Earlier WebEssentials gave option to retain comments which is missing now
This option has been moved into Project Properties in Visual Studio 2013 + TypeScript 0.9.5 onwards :
http://blogs.msdn.com/b/typescript/archive/2013/12/05/announcing-typescript-0-9-5.aspx
If you are on an older version of visual studio you can bypass the visual studio build pipeline and maintain it externally using something like grunt-ts : https://github.com/grunt-ts/grunt-ts#compiler-support
I've been stuck with the unpleasant task of "unminifying" a minified JavaScript code file. Using JSBeautifier, the resulting file is about 6000 lines long.
Ordinarily, the variable and parameter names would be permanently lost, but in this case, I have an obsolete version of the original file that the minified JavaScript code file was generated from. This obsolete version of the original file contains most of the code comments and variable names, but absolutely cannot be used in place of the current version.
I would like to know if there is some way of renaming all instances of a particular parameter or variable in JavaScript. Since minification reduces the names to a single character, find-and-replace is impossible.
Is there some tool out there, which I can tell, in this file, the parameter a to function foo should be clientName and have it semantically rename all instances of that parameter to clientName?
Unfortunately, I work for a large organization with an approved list of software and I am stuck with Visual Studio 2010 for the forseeable future (no VS 2012).
Update: #Kos, we don't use Git, but we do use source control. The problem is that a developer who doesn't work for my organization anymore once made changes to the file, minified it, and only checked in the minified version to source control, so his changes to the original have been lost.
I'm a year late for this answer, but I had a similar problem to yours so I built this: https://github.com/zertosh/beautify-with-words. It unminifies code using UglifyJS2 but uses a phonetic word generator to rename variables. You get "long-ish" variable names so it's a breeze to do a find-and-replace. Hope this helps someone else!
You might have another way out.
Check out the last unminified version of the code. Compare to the minified version. Arguably most of it should be the same modulo consistent variable renaming. The differences you'll have to rename and remerge.
Diff won't do this kind of compare; you need tools that compare the programs as code, not text. Our SmartDifferencer tool will do this (by using language-specific full parsers to generate ASTs, and then comparing the ASTs); in effect, it compares the programs in spite of whitepspacing. SmartDifferencer also handles renaming; if two file are identical modulo a single renaming, that's what SmartDifferencer tell you.
I don't know how well this work work out; we haven't tried SmartDifferencer with 6000 lines of "consistently renamed" variables.
I found that a Visual Studio extension we've licensed here called "Telerik JustCode" has functionality to do what I want.
I am running Eclipse 3.6 (Helios 20110218-0911) on Ubuntu 11.04. Under Preferences, I have gone to the following panel:
JavaScript -> Editor -> Save Actions.
The "Additional actions" checkbox is checked and "Remove trailing whitespaces on all lines" is selected.
Nevertheless, when I save my JavaScript file in Eclipse, there is still trailing whitespace at the end of my lines.
What am I missing?
'Save Actions' for JavaScript is available in the JavaScript project(the project with JavaScript nature) only.
(If you can see 'Convert to JavaScript Project' in 'Configure' menu when right-click the project, try it)
I recently faced the same problem. The only way I found is to convert your project to Javascript project. Right click your project folder in the Explorer, choose [Configure] -> [Convert to Javascript project] and the Javascript Save Action will start to work.
Unfortunately, I don't know how to convert it back.
Since it's not a big problem for me, the way Converting it to javascript project indeed helps me a lot.
For the latest Eclipse -
Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200
The default key-binding shift+ctrl+backspace, which binds to the function "Removes the trailing whitespace of each line" will remove trailing space chars for the entire file.
(The key-binding shift+ctrl+backspace is probably already there in many earlier releases as well.)