Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into vim9
Browse files Browse the repository at this point in the history
  • Loading branch information
kg8m committed Mar 16, 2024
2 parents e68eb90 + 10f8bc2 commit a8b6c5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Disable formatting of quoted code embedded in a file because it breaks sample codes in the README.md.
# https://prettier.io/docs/en/options.html#embedded-language-formatting
embeddedLanguageFormatting: off
61 changes: 12 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![test](https://github.com/kg8m/vim-simple-align/actions/workflows/test.yml/badge.svg?branch=vim9)](https://github.com/kg8m/vim-simple-align/actions/workflows/test.yml?query=branch%3Avim9)


vim-simple-align
==================================================
# vim-simple-align

A Vim/Neovim plugin to align texts by simple way.

* vim-simple-align provides only 1 command and a few its options
* no need to remember options because they can be completed
* delimiter used to split texts is always Vim's regular expression
- vim-simple-align provides only 1 command and a few its options
- no need to remember options because they can be completed
- delimiter used to split texts is always Vim's regular expression

vim-simple-align doesn't cover all alignment cases but aims to work nice in many common cases.

https://user-images.githubusercontent.com/694547/119252181-beec6380-bbe5-11eb-87ce-4ed643598962.mp4


Commands/Usage
--------------------------------------------------
## Commands/Usage

vim-simple-align provides only 1 command: `:SimpleAlign`.

Expand All @@ -38,7 +34,6 @@ Delimiter is Vim's regular expression. Some characters may need to be escaped.

cf. `:h regular-expression`


### Options

#### `-count` (`-c`) option
Expand All @@ -47,30 +42,25 @@ cf. `:h regular-expression`

Default: `-1`


#### `-lpadding` (`-l`) option

`-lpadding` option means how many spaces to put left padding of each token. Available values are integers greater than or equal to 0.

Default: `1`


#### `-rpadding` (`-r`) option

`-rpadding` option means how many spaces to put right padding of each token. Available values are integers greater than or equal to 0.

Default: `1`


#### `-justify` (`-j`) option

`-justify` option means which side tokens should be on. Available values are `left` and `right`.

Default: `left`


Examples
--------------------------------------------------
## Examples

### Align Markdown table

Expand All @@ -90,14 +80,12 @@ a | bbb | ccccc
| .. | .. | .. |
```


#### 🔧 Command

```vim
:1,4SimpleAlign |
```


#### ⭕️ Aligned

```md
Expand All @@ -114,7 +102,6 @@ a | bbb | ccccc
| .. | .. | .. |
```


### Align Markdown table with justifying to right

#### ❌ Not aligned
Expand All @@ -133,14 +120,12 @@ a | bbb | ccccc
| .. | .. | .. |
```


#### 🔧 Command

```vim
:1,4SimpleAlign | -justify right
```


#### ⭕️ Aligned

```md
Expand All @@ -157,7 +142,6 @@ a | bbb | ccccc
| .. | .. | .. |
```


### Align JSON, dictionary/hash items

#### ❌ Not aligned
Expand Down Expand Up @@ -192,7 +176,6 @@ Ruby old Hash syntax:
}
```


#### 🔧 Command

For JSON:
Expand All @@ -213,7 +196,6 @@ For Ruby old Hash syntax:
:2,4SimpleAlign =>
```


#### ⭕️ Aligned

JSON:
Expand Down Expand Up @@ -246,7 +228,6 @@ Ruby old Hash syntax:
}
```


### Align variable assignments

#### ❌ Not aligned
Expand Down Expand Up @@ -275,7 +256,6 @@ a = "a"
a += "a"
```


#### 🔧 Command

For basic case:
Expand All @@ -296,7 +276,6 @@ For `=` and `+=`:
:1,2SimpleAlign [+\ ]=
```


#### ⭕️ Aligned

Basic case:
Expand All @@ -323,7 +302,6 @@ a = "a"
a += "a"
```


### Align output/result comments

#### ❌ Not aligned
Expand All @@ -344,7 +322,6 @@ bbb #=> "bbb"
ccccc #=> "ccccc"
```


#### 🔧 Command

For JavaScript:
Expand All @@ -359,7 +336,6 @@ For Ruby:
:1,3SimpleAlign #=> -lpadding 2
```


#### ⭕️ Aligned

JavaScript:
Expand All @@ -378,7 +354,6 @@ bbb #=> "bbb"
ccccc #=> "ccccc"
```


### Align non-whitespace characters

#### ❌ Not aligned
Expand All @@ -390,14 +365,12 @@ t.boolean :active, null: false, default: true
t.boolean :foo, null: true, default: false
```


#### 🔧 Command

```vim
:1,4SimpleAlign \S\+ -lpadding 0
```


#### ⭕️ Aligned

```rb
Expand All @@ -407,21 +380,15 @@ t.boolean :active, null: false, default: true
t.boolean :foo, null: true, default: false
```

## Inspired by alignta

Inspired by alignta
--------------------------------------------------

vim-simple-align is inspired by [h1mesuke/vim-alignta](<https://github.com/h1mesuke/vim-alignta>). It is a simple Vim plugin to align texts. It provides only 1 command `:Alignta` and has a few options and command syntaxes. It is a very great plugin but doesn't work on current Vim. vim-simple-align inherits its philosophy and focuses its limited essential features.

vim-simple-align is inspired by [h1mesuke/vim-alignta](https://github.com/h1mesuke/vim-alignta). It is a simple Vim plugin to align texts. It provides only 1 command `:Alignta` and has a few options and command syntaxes. It is a very great plugin but doesn't work on current Vim. vim-simple-align inherits its philosophy and focuses its limited essential features.

Why not vim-easy-align?
--------------------------------------------------
## Why not vim-easy-align?

Yes, [vim-easy-align](https://github.com/junegunn/vim-easy-align) is a great Vim plugin. However, it is complicated and difficult for me. I can't remember its mappings, options, and syntaxes. It is a so cool product, but not for me.


Installation
--------------------------------------------------
## Installation

If you use [dein.vim](https://github.com/Shougo/dein.vim):

Expand All @@ -431,18 +398,14 @@ call dein#add("kg8m/vim-simple-align")

Note: dein.vim's lazy loading feature with `on_cmd` option is not recommended for vim-simple-align. You will see `E471: Argument required: ...` if so. To tell the truth, lazy loading of vim-simple-align doesn't make Vim's startup faster. On the one hand, vim-simple-align just defines 1 command when added to `runtimepath`. On the other hand, dein.vim's lazy loading with `on_cmd` also defines a dummy command.


Vim9 script
--------------------------------------------------
## Vim9 script

You can use Vim9 script version if you use Vim 8.2.4053+. Vim9 script version is 5-10 times faster than legacy Vim script version. Vim9 script version is available on [`vim9` branch](https://github.com/kg8m/vim-simple-align/tree/vim9).

```vim
call dein#add("kg8m/vim-simple-align", { "rev": "vim9" })
```


Requirements
--------------------------------------------------
## Requirements

Vim 8.2+ or Neovim nightly

0 comments on commit a8b6c5b

Please sign in to comment.