janjoerke / vscode-align-by-regex Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I tried to align this table:
I|have|a|table
It|is|not|aligned
with Regex '\|' and got the following:
I |have|a|table
It|is|not|aligned
I have a file with comments, like:
function blah() { "hi there" }
# This function does amazing things the likes of which you have never seen.
function longerfunc() { "hi there" }
Actual:
Aligning against "{" creates this:
function blah() { "hi there"}
# This function does amazing things the likes of which you have never seen.
function longerfunc() { "hi there"}
Expected:
I expected it to ignore non-matching lines and create this:
function blah() { "hi there"}
// This function does amazing things the likes of which you have never seen.
function longerfunc() { "hi there"}
Because of non-latin characters may occupy more than one cell.
May use a package such as wcwidth
to calculate unicode characters.
Here's an example:
Input:
a(123) // 123
bb(45) // 45
ccc(6) // 6
Align by Regex: \(
Output:
a (123) // 123
bb (45) // 45
ccc(6) // 6
Expected:
a (123) // 123
bb (45) // 45
ccc(6) // 6
For some reason, the command changed the number of spaces after the match point.
The expectation is that everything after the match would remain unchanged, but only the match point will be aligned.
in Windows, shift+alt+a is set to toggle block comment,
I don't know how is in MacOS,
but It is really confuse to over write the default shout cut for user to use.
may be we could change to shift+alt+=
This would allow, e.g., the following keyboard shortcuts
{
"key": "shift+alt+=",
"command": "align.by.regex",
"args": "=",
"when": "editorHasSelection"
}
{
"key": "shift+alt+[",
"command": "align.by.regex",
"args": "[",
"when": "editorHasSelection"
}
Tabs are counted as single characters. VSCode has the tab size setting editor.tabSize
which should make it possible to align with tabs.
Failing case:
a.
b.
(b is indented with tab)
after aligning by dot (".") becomes
a .
b.
The . is aligned on index 2. Dot on second line is also index 2, but looks like index 5 if your tab size is 4.
Just tried out the version 1.0.2. I tried aligning a markdown table, e.g.
I|have|a|table
It|is|not|aligned
I accidentally entered '|' instead of escaping it as '\|' and after that my computer started heating up and I couldn't call up the command menu in VSCode.
It would be great to see Live Preview mode like in AlignTab sublime package. It is possible with VS Code API?
Hi
is it possible to "select" the character of alignement ?
For example, i have the following code (it is from a constraint XDC file but whatever)
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN } [get_ports RXDATA_A[7] ]
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN } [get_ports RX_A[0] ]
If i use the extenstion to align with ']' i've got:
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN } [get_ports RXDATA_A[7] ]
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN } [get_ports RX_A[0 ] ]
But what i want is:
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN } [get_ports RXDATA_A[7] ]
set_property -dict {IOSTANDARD LVCMOS33 PACKAGE_PIN } [get_ports RX_A[0] ]
i would like to configure alignbyregex to align to the Nth character not the first one.
After selecting a set of lines, the end of the selection is often at the beginning of the next line, which causes the plugin to include that line in the alignment. This is unexpected behavior since no part of the line is actually selected.
a - 1
ab - 2
abcd - 4
abcdefg - 8
abcdefghijklmno - 16
Expected Behavior:
Aligns the first three lines:
a - 1
ab - 2
abcd - 4
abcdefg - 8
abcdefghijklmno - 16
Actual Behavior:
Aligns the first four lines:
a - 1
ab - 2
abcd - 4
abcdefg - 8
abcdefghijklmno - 16
Is it possible to ignore comment line when alignment is performed ?
For example, i work on VHDL file:
`-- This line is a long comment ( if bar <= 2 it is ko )
foo <= bar(2 downto 0);
long_long__name <= '0';
`
I want to align my code with '<=' but only on "real" code line.
Thanks.
could you please publish this extension on open-vsx.org? I switched to vscodium, so this really useful addon is no longer available for me, and this kinda sucks in my day-to-day work. i'd be really grateful :)
I propose that the template system be expanded to
SomeWord
is translated to (SomeRegEx)
"align.by.regex.showTemplates"
// shows a searchable command palette list of user's "align.by.regex.templates"
"align.by.regex.templates": {
"SomeWord": "(SomeRegEx)",
}
"align.by.regex.interpolationPrefix" = "{{"
"align.by.regex.interpolationSuffix" = "}}"
"align.by.regex.interpolationMode"
// "plainText":
// - user input "SomeWord" will be translated to "(SomeRegEx)"
// "interpolate":
// - implements "align.by.regex.interpolationPrefix"
// & "align.by.regex.interpolationSuffix" settings
// - user input "SomeWord" will be translated to "SomeWord"
// - user input "1{{SomeWord}}2" will be translated to "1(SomeRegEx)2"
// "none":
// - templates are only available via the "align.by.regex.showTemplates" command
"align.by.regex.interpolationCaseSensitive"
// true
// - user input "SomeWord" will be translated to "(SomeRegEx)"
// - user input "someword" will be translated to "someword"
// false
// - user input "SomeWord" will be translated to "(SomeRegEx)"
// - user input "someword" will be translated to "(SomeRegEx)"
Hi
Maybe i'm making a mistake into configuration, but is it possible to have template with escape characters ?
For exemple, i want to create a template to align with parenthesis. But in regex in must escape parenthesis. So i've created the following template:
parent = "(|)"
But vscode, says me that is an unvalid escape character.
How can i do this type of template ?
Thanks.
When I have a text with long lines, e.g.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
And I use align by regex, it aligns correctly but mashes together the words at the ends of long lines (I aligned by comma, but it doesn't render correctly on Github).
Lorem ipsum dolor sit amet , consectetur adipiscing elit , sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodoconsequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id estlaborum.
I'm using this plugin to align my tests, which tend to have a lot of semi-short tests, sprinkled alongside a very small smattering of super-long ones (this is just a small sample for reference):
#[test] fn declare_missing_right() { expect( "a: ; a" ).to_error( MissingOperand, 1..=1 ) }
#[test] fn declare_missing_left() { expect( ": 1" ).to_error( MissingOperand, 0..=0 ) }
#[test] fn declare_missing_both() { expect( ":" ).to_error( MissingOperand, 0..=0 ) }
#[test] fn declare_precedence() { expect( "a: false; b: false || true && 14 == 2 + 3 * 4; b" ).to_yield( true ) }
#[test] fn declare_non_field() { expect( "1: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=0 ) }
#[test] fn declare_non_field_expr() { expect( "1+2: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=2 ) }
Current Behavior:
Currently, aligning by {|\)\.
(rightly) causes all the lines to be aligned to the long one. This makes the whole file feel out of whack:
#[test] fn declare_missing_right() { expect( "a: ; a" ).to_error( MissingOperand, 1..=1 )}
#[test] fn declare_missing_left() { expect( ": 1" ).to_error( MissingOperand, 0..=0 )}
#[test] fn declare_missing_both() { expect( ":" ).to_error( MissingOperand, 0..=0 )}
#[test] fn declare_precedence() { expect( "a: false; b: false || true && 14 == 2 + 3 * 4; b" ).to_yield( true )}
#[test] fn declare_non_field() { expect( "1: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=0 )}
#[test] fn declare_non_field_expr() { expect( "1+2: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=2 )}
Desired Behavior:
I'd like to be able to either (a) let me specify maximums, or even better, (b) have it use some kind of outlier detection (like, pick things close to the P90--i.e. if there are a hundred lines, pick the length of the 90th line instead of the 100th), or (b) specify a maximum indent to keep the file from getting too hard to read. I'd like it to look like this, in short:
#[test] fn declare_missing_right() { expect( "a: ; a" ).to_error( MissingOperand, 1..=1)}
#[test] fn declare_missing_left() { expect( ": 1" ).to_error( MissingOperand, 0..=0)}
#[test] fn declare_missing_both() { expect( ":" ).to_error( MissingOperand, 0..=0)}
#[test] fn declare_non_field() { expect( "1: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=0)}
#[test] fn declare_non_field_expr() { expect( "1+2: 1" ).to_error( AssignmentTargetMustBeIdentifier, 0..=2)}
#[test] fn declare_precedence() { expect( "a: false; b: false || true && 14 == 2 + 3 * 4; b" ).to_yield( true )}
It seems that the aligner modifies the text prior the match point.
That is not expected.
Example:
Original text:
a a(aaa)
b b(bbbb)
c c(c)
d d(ddddddd)
Align By Regex: \).*$
Result:
a a(aaa )
b b(bbbb )
c c(c )
d d(ddddddd)
Expected:
a a(aaa )
b b(bbbb )
c c(c )
d d(ddddddd)
the position of the text before the match point has been modified.
My expectation was that only the match and text after it will be moved.
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.