Giter Site home page Giter Site logo

auto-align's Introduction

Auto Align

video

This is basically a poor man's spreadsheet. It auto formats a file, aligning columns by padding with spaces. It uses commas for .csv files and vertical bars for .bsv files. You can also add other separators for other file types if you want.

It will find the first and last lines in the file containing the separator and format all lines between.

When active, the tab key will move to the next field and shift+tab will move to the previous field.

Alignment can also be triggered manually using Auto Align: Align Columns, Auto Align: Align Selection or Auto Align: Align Selection With Separator.

Note: This works well with reasonably small files. With a 2000 line, 10 column file it's still usable. With 10000 lines it starts to lag a bit. I wrote this because I often feel the need to write files in a simple table format, but don't want to use Excel. You may want to take a copy of your file first, just to be safe.

  • Highlight headings in bold (or something)
  • Add sort functionality
  • Add warning if file already contains new separator
  • Add methods to insert/remove empty columns

Installing

You can install the latest version of the extension via the Visual Studio Marketplace here.

Alternatively, open Visual Studio code, press Ctrl+P or Cmd+P and type:

> ext install auto-align

Source Code

The source code is available on GitHub here.

Configuration

autoAlign.associations

This defines which files will be auto aligned, and what separator to use. By default it sets .csv files to commas, and .bsv files to vertical bars. The separator is used as part of a regex. Single character separators are automatically escaped, but if you need a more complicated separator, you may need to escape other characters.

The separator for the current file type can be changed with the 'Auto Align: Change Separator' command.

autoAlign.enabled

Set this to false to disable auto formatting for the associated file extension.

This flag can be set using the command 'Auto Align: Enable auto align mode' and 'Auto Align: Disable auto align mode'. Alternatively, it can be quickly changed by clicking the 'Auto Align' button on the status bar.

autoAlign.delay

This is the delay after which the file is formatted when you stop typing.

autoAlign.dimSeparator

When auto align is enabled, the separators are dimmed to aid readability. Set this to false if you would prefer not to dim them.

autoAlign.collapseOnDisable

If set to true, the fields will all be collapsed (spaces trimmed) when auto align is disabled. The file can also be collapsed manually using the 'Auto Align: Format' command if auto align is not enabled.

autoAlign.extraSpace

By default, an extra space is inserted after the separator to aid readability. If you don't want this, set this flag to false.

autoAlign.endingSeparator

Set to true add an aligned trailing separator.

autoAlign.repositionCursor

Normally, after formatting, an attempt is made to reposition the cursor somewhere sensible. If this gets annoying, you can disable this by setting this to false.

Credits

I shamelessly stole the alignment code from dakara's Transformer extension.

Icon from deleket.

Regex for matching separators unless quoted by Stack Overflow user hwnd.

auto-align's People

Contributors

gruntfuggly avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.