warwithinme / better-align Goto Github PK
View Code? Open in Web Editor NEWA vscode extension to provide better vertical alignment
License: Other
A vscode extension to provide better vertical alignment
License: Other
I'd like to also align additional symbols such as ::
, .
, ->
, <-
, etc. It probably doesn't make sense to keep extending this plugin with every possible symbol, but it might be feasible to allow both global and per-language symbol customization. Something like:
"alignment.symbols": {
"global": [ "..." ],
"purescript": [ "=", "==", "/=", "::", ".", "->", "<-" ]
}
Before:
num_of_azs . = "${var.num_of_azs}"
cidr = "${var.cidr}"
private_subnet_suffix = "${var.private_subnet_suffix}"
private_subnets = "${var.private_subnets}"
After:
num_of_azs = "${var.num_of_azs}"
cidr = "${var.cidr}"
private_subnet_suffix = "${var.private_subnet_suffix}"
private_subnets = "${var.private_subnets}"
Can this plugin be ported to visualstudio?
I use php and when i need to align an array declaration:
$data = array(
'text' => 'something',
'here is another' => 'sample'
);
Gets converted to:
$data = array(
'text' = > 'something',
'here is another' = > 'sample'
);
It does the alignment beautifully! But changes => to = > (space added) and breaks the code.
this ext is smart , how to auto align on file saved?
Can I align code which looks like this? or do you hope to add this to another release perhaps?
detailView: boolean = true;
selectedEmployee: EmployeeProfile;
weekNo: number = 0;
There is a problem with the syntax of JavaScript. For '===', the plugin will format it as '= ==', which is obviously not what we want, which will cause a syntax error.
It would be really nice if this could also align imports:
from:
import React, { Component } from 'react';
import autoBind from 'react-autobind';
import PropTypes from 'prop-types';
import { List } from 'immutable';
import cx from 'classnames';
To:
import React, { Component } from 'react';
import autoBind from 'react-autobind';
import PropTypes from 'prop-types';
import { List } from 'immutable';
import cx from 'classnames';
Hi! Great extentions.
Could You add support for 'from' to align imports. Or maybe an option to set custom delimiters.
Thanks!
Since extension sometimes breaks something or we don't want something to align for some reason it would be awesome to introduce "ignore" tags:
... code that can be aligned
... code that can be aligned
... code that can be aligned// @better-align-disable
... code that must not be aligned !
// @better-align-enable
... code that can be aligned
... code that can be aligned
... code that can be aligned
Thank you for a great extension!
Is there any way to make it align ES6 imports?
eg:
import React from 'react'
import ReactNative from 'react-native'
import styleSheet from './section.style'
import SectionRow from './section-row'
=>
import React from 'react'
import ReactNative from 'react-native'
import styleSheet from './section.style'
import SectionRow from './section-row'
Align this code.
articlesSubject$: Subject<Article[]>;
articles$ : Observable<Article[]>; // Final Observable
readonly nextFunc : (value: Article[]) => void = v => this.articlesSubject$.next(v);
Gives.
articlesSubject$: Subject<Article[]>;
articles$ : Observable<Article[]>; // Final Observable
readonly nextFunc : (value: Article[]) => void = v => this.articlesSubject$.next(v);
Align again.
articlesSubject$: Subject<Article[]>;
articles$ : Observable<Article[]>; // Final Observable
readonly nextFunc : (value: Article[]) => void = v => this.articlesSubject$.next(v);
This aligns normally.
articlesSubject$: Subject<Article[]>;
articles$ : Observable<Article[]>; // Final Observable
readonly nextFunc = v => this.articlesSubject$.next(v);
Is there any chance that we can add support for "visually" alignment? By that I mean no spaces should be added to the code itself but the IDE appears these spaces to make it aligned.
If so, there's no need to worry about eslint errors or collaboration conflicts, etc.
Or, we could add a setting to only commit the unaligned code in Git but when come back to IDE, make it better-aligned?
Better ideas?
OMG! This extension is the best! 👏👏👏
It would be very useful to align long lines which are wrapped.
Example:
VSCode current format (simple indentation):
return veryLongThing1() && veryLongThing2()
|| someOtherThing1() && someOtherThing2();
somePromise.then(doSomething)
.then(doSomethingElse)
.catch(handleError);
Better Align
would look like:
return veryLongThing1() && veryLongThing2() // Space padding before `&&`
|| someOtherThing1() && someOtherThing2(); // First expression aligned to first expression on first line
// Aligned dots for function chaining
somePromise.then(doSomething)
.then(doSomethingElse)
.catch(handleError);
Cheers and happy coding 🥂
is it not support .= asignment ?
could you please support #define
and functions in the header file like:
// Original code
#define DEFINE_1 DEFINE
#define ANOTHER_DEFINE_1 DEFINE_1
// after use align
#define DEFINE_1 DEFINE
#define ANOTHER_DEFINE_1 DEFINE_1
in functions
// Original code
int firstFunctions();
unsigned int secondFunctions();
void thirstFunction();
// after use align
int firstFunctions();
unsigned int secondFunctions();
void thirstFunction();
on v 1.1.3, when aligning the following line:
result += 'Some text'
it gets replaced with
result = 'Some text'
Note the missing +.
I'd like to disable alignment by colon ":" for erlang files
See my snippets below
If I align this
{ok, Pid} = supervisor:start_child(Sup, Args),
NewRef = erlang:monitor(process, Pid),
NewRefs = gb_sets:insert(NewRef, gb_sets:delete(Ref, Refs)),
gen_server:reply(From, {ok, Pid}), % <---- See there is no "=" sign
Then I get
{ok, Pid} = supervisor: start_child(Sup, Args),
NewRef = erlang : monitor(process, Pid),
NewRefs = gb_sets : insert(NewRef, gb_sets:delete(Ref, Refs)),
gen_server : reply(From, {ok, Pid}), % <---- See there is no "=" sign```
But I want this:
{ok, Pid} = supervisor:start_child(Sup, Args),
NewRef = erlang:monitor(process, Pid),
NewRefs = gb_sets:insert(NewRef, gb_sets:delete(Ref, Refs)),
gen_server:reply(From, {ok, Pid}), % <---- See there is no "=" sign
Could you please add a configurations keys for tokens which may be aligned by?
Thank you in advance
How can i align only comments?Editing the option "comment" : spaces, doesn't help for proper alignment of comments.
Is there a configuration to exclude some files. For example, I don't want package.json to be aligned automatically.
Thanks
Anand
I noticed that it doesn't recognize .func() for alignment for example:
taking this
return gulp.src(jsFiles)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat('bundle.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./content'));
and making it
return gulp.src(jsFiles)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat('bundle.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./content'));
I am not sure how difficult this would as I have never worked with the language you are using.
When Better Align is installed, typing a semi-colon in the terminal does not work.
Is it possible to use this with beautify?
Thanks
I use Haskell where ==
is the comparation operator; it must not be split into = =
by align.
The tool would be helpful, especially to make list re-aligned with leading ,
.
The current formatting rules will break bash scripts (sh, bash, zsh, etc)
export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_CACHE_HOME="${HOME}/.cache"
export XDG_DATA_HOME="${HOME}/.local/share"
export XDG_RUNTIME_DIR="$XDG_CACHE_HOME"
export ZPLUG_HOME="${HOME}/.zplug"
export ZSH_DIR="${XDG_CONFIG_HOME}/zsh"
export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_CACHE_HOME="${HOME}/.cache"
export XDG_DATA_HOME="${HOME}/.local/share"
export XDG_RUNTIME_DIR="$XDG_CACHE_HOME"
export ZPLUG_HOME="${HOME}/.zplug"
export ZSH_DIR="${XDG_CONFIG_HOME}/zsh"
export XDG_CONFIG_HOME = "${HOME}/.config"
export XDG_CACHE_HOME = "${HOME}/.cache"
export XDG_DATA_HOME = "${HOME}/.local/share"
export XDG_RUNTIME_DIR = "$XDG_CACHE_HOME"
export ZPLUG_HOME = "${HOME}/.zplug"
export ZSH_DIR = "${XDG_CONFIG_HOME}/zsh"
Spaces around the =
in most any shell script will break the assignment, alias, export, and others. They should be aligned on the =
but have no spaces around them. Instead, the spaces should be inserted before the left hand side.
Hi,
There's a bug with CSS pseudo-classes and multiple selectors separated by new line.
Input:
a:hover,
a:visited {
}
Output:
a: hover,
a: visited {
}
multiple selectors with pseudo-classes on the same line works fine.
a:hover,a: visited {
}
Installed this extension and added the shortcut:
{ "key": "ctrl+cmd+=", "command": "wwm.aligncode",
"when": "editorTextFocus && !editorReadonly" }
Is there any way to make this align javascript objects by value instead of by colon? The plugin currently takes an object and does this:
{
a: 'a',
asdf: 'sldfk',
klj: 'lksjdlk',
}
=>
{
a : 'a',
asdf: 'sldfk',
klj : 'lksjdlk',
}
But I would rather it keep the colon next to the key and align the vlaues, like this:
{
a: 'a',
asdf: 'sldfk',
klj: 'lksjdlk',
}
Is there a built in setting that would allow this to be configured?
It doesn't seem to work with nested arrays. In the example below the first part of the array (all the way to the key "wrapper"), is aligned correctly. But it doesn't align anything below the "wrapper" key. So when I give the command to align the bottom part (after "wrapper"), it aligns it but it ignores the top part spacing, and does its own spacing. So I ended up with one array where the first section is aligned to a certain amount of spacing and the second part to another. This seems to happen anytime it finds a nested array.
What's happening:
Hi @WarWithinMe, thanks for the plugin! The plugin currently uses space to align. This throws up errors with eslint etc, if you are using tabs in your project elsewhere. In those cases, even just for consistency, one would like to use tabs to align.
Do you think the plugin could support an option for spaces vs tabs?
v 1.1.6
I am having an issue where the colon of ternary statements are being effected as well when aligning properties of an object. Please see the screenshot below for the results of my values after using the align command.
The false values are pushed so far right because of longer property values set above the screenshot.
When writing Python code (indentation set at 4 spaces)...
Aligning this:
var1 = 123 # first var
var999 = 99981 # bigger var
Produces this:
var1 = 123 # first var
var999 = 99981 # bigger var
But I'd like this:
var1 = 123 # first var
var999 = 99981 # bigger var
If I have the following (Ruby) code:
do_the_thing(on: me,
with: it,
using: flamethrower,
ignoring: nil)
and I invoke Align on the with: it
line, the result is:
do_the_thing(on: me,
with: it,
using: flamethrower,
ignoring: nil)
It would be great if it could align all the arguments, including the one on the line with the open-paren, to produce the following:
do_the_thing(on: me,
with: it,
using: flamethrower,
ignoring: nil)
pGetTFs = proc()
pGetTFs.input = "cedir:file"
pGetTFs.output = "outfile:file:{{cedir | fn}}.tfs.txt"
pGetTFs.script = """
awk '({{genes | map(lambda x: '$4 == "'+x+'"' , _) | " || ".join(_)}}) {print $2}' {{cedir}} /*.coexp.txt | sort | uniq > "{{outfile}}"
# ^^
"""
After alignment:
pGetTFs = proc()
pGetTFs.input = "cedir:file"
pGetTFs.output = "outfile:file:{{cedir | fn}}.tfs.txt"
pGetTFs.script = """
awk '({{genes | map(lambda x: '$4 = = "'+x+'"' , _) | " || ".join(_)}}) {print $2}' {{cedir}} /*.coexp.txt | sort | uniq > "{{outfile}}"
# ^^^
"""
A possible solution is to detect whether there is a =
right after =
. In most cases, double =
means equality check instead of assignment.
Original code
alist = list(a=1,b=2)
alist[["a"]] = 3
alist$b = 4
After align:
alist = list(a=1,b=2)
alist[["a"]] = 3
alist$b = 4
Expected:
alist = list(a=1,b=2)
alist[["a"]] = 3
alist$b = 4
All options are left as default.
I use matlab and the plugin always breaks operators like "==" "~=" "<=" ">="
is it possible to be fixed?
Nice shot.
I wish I could use it with other languages like VBS. For instance, I can not align this VBS code block:
Dim fAnime : fAnime = 0 ' Remove Bracket and its content "[Hyogo]_Naruto_Shippuuden_143_VOSTFR_[400p]_[Xvid-Mp3]_[FADDA119](1280x720x264AAC)" will results "Naruto_Shippuuden_143_VOSTFR"
Dim fBracket : fBracket = 0 ' Replace "[]" with "()"
Dim fBrakSpace : fBrakSpace = 1 ' Put a space around brackets
Dim fComSpace : fComSpace = 1 ' Put a space after comma
Dim fDot : fDot = 1 ' Dots to spaces except for numbers & extension
Dim fExtLCase : fExtLCase = 1 ' Make extension lower case
Dim fManga : fManga = 0 ' Add "0" before volume and chapter, i.e.: "Kenichi - v2 - c8 - 01.jpg" to "Kenichi - v02 - c08 - 01.jpg"
like this:
Dim fAnime : fAnime = 0 ' Remove Bracket and its content "[Hyogo]_Naruto_Shippuuden_143_VOSTFR_[400p]_[Xvid-Mp3]_[FADDA119](1280x720x264AAC)" will results "Naruto_Shippuuden_143_VOSTFR"
Dim fBracket : fBracket = 0 ' Replace "[]" with "()"
Dim fBrakSpace : fBrakSpace = 1 ' Put a space around brackets
Dim fComSpace : fComSpace = 1 ' Put a space after comma
Dim fDot : fDot = 1 ' Dots to spaces except for numbers & extension
Dim fExtLCase : fExtLCase = 1 ' Make extension lower case
Dim fManga : fManga = 0 ' Add "0" before volume and chapter, i.e.: "Kenichi - v2 - c8 - 01.jpg" to "Kenichi - v02 - c08 - 01.jpg"
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.