Skip to content

esert/align_whitespace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Align Whitespace

Align C/C++ declaration, assignment, parameter, call, and macro blocks around the active cursor line.

Examples:

int a;
float b;

becomes:

int   a;
float b;
MyStruct foobar = {1, 2, 3};
YourStruct bax = {};
HisStruct baz = {5};

becomes:

MyStruct   foobar = {1, 2, 3};
YourStruct bax    = {};
HisStruct  baz    = {5};
int lerp(
    int a,
    int b,
    float r,
);

becomes:

int lerp(
    int   a,
    int   b,
    float r,
);
int x = lerp(1, 2, 0.5f);
float xx = lerp(11, 22, 1);

becomes:

int   x  = lerp(1,  2,  0.5f);
float xx = lerp(11, 22, 1   );
value += 1;
longestName = 22;
third -= 333;

becomes:

value       += 1;
longestName  = 22;
third       -= 333;
#define FOO(X) \
    X(a, 1, 2) \
    X(aa, 11, 22) \
    X(aaa, 111, 222)

becomes:

#define FOO(X)      \
    X(a,   1,   2)  \
    X(aa,  11,  22) \
    X(aaa, 111, 222)

Command

  • Align Whitespace: C/C++ Block

Default keybinding

  • F1 for *.cpp, *.cc, *.cxx, *.h, *.hpp

Notes

  • For normal same-indent blocks, alignment is limited to the contiguous active run containing the cursor.
  • Inactive rows break the active run. If the cursor is on an inactive row, nothing happens.
  • Assignment-only rows like value += 1; align together and are kept separate from declaration-style rows like int x = 1;.
  • Compound assignment operators align on the = character, so +=, -=, |=, etc. share the same operator column as =.
  • The alignment logic is implemented in python/align_cpp_block.py.
  • The extension shim in extension.js only registers the VS Code command and invokes Python.
  • The default Python command is python3. You can change it with the alignWhitespace.pythonCommand setting.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors