diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..2ce3586 --- /dev/null +++ b/.prettierrc.yml @@ -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 diff --git a/README.md b/README.md index 1b59217..f81b029 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -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 @@ -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 @@ -90,14 +80,12 @@ a | bbb | ccccc | .. | .. | .. | ``` - #### 🔧 Command ```vim :1,4SimpleAlign | ``` - #### ⭕️ Aligned ```md @@ -114,7 +102,6 @@ a | bbb | ccccc | .. | .. | .. | ``` - ### Align Markdown table with justifying to right #### ❌ Not aligned @@ -133,14 +120,12 @@ a | bbb | ccccc | .. | .. | .. | ``` - #### 🔧 Command ```vim :1,4SimpleAlign | -justify right ``` - #### ⭕️ Aligned ```md @@ -157,7 +142,6 @@ a | bbb | ccccc | .. | .. | .. | ``` - ### Align JSON, dictionary/hash items #### ❌ Not aligned @@ -192,7 +176,6 @@ Ruby old Hash syntax: } ``` - #### 🔧 Command For JSON: @@ -213,7 +196,6 @@ For Ruby old Hash syntax: :2,4SimpleAlign => ``` - #### ⭕️ Aligned JSON: @@ -246,7 +228,6 @@ Ruby old Hash syntax: } ``` - ### Align variable assignments #### ❌ Not aligned @@ -275,7 +256,6 @@ a = "a" a += "a" ``` - #### 🔧 Command For basic case: @@ -296,7 +276,6 @@ For `=` and `+=`: :1,2SimpleAlign [+\ ]= ``` - #### ⭕️ Aligned Basic case: @@ -323,7 +302,6 @@ a = "a" a += "a" ``` - ### Align output/result comments #### ❌ Not aligned @@ -344,7 +322,6 @@ bbb #=> "bbb" ccccc #=> "ccccc" ``` - #### 🔧 Command For JavaScript: @@ -359,7 +336,6 @@ For Ruby: :1,3SimpleAlign #=> -lpadding 2 ``` - #### ⭕️ Aligned JavaScript: @@ -378,7 +354,6 @@ bbb #=> "bbb" ccccc #=> "ccccc" ``` - ### Align non-whitespace characters #### ❌ Not aligned @@ -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 @@ -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](). 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): @@ -431,9 +398,7 @@ 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). @@ -441,8 +406,6 @@ You can use Vim9 script version if you use Vim 8.2.4053+. Vim9 script version is call dein#add("kg8m/vim-simple-align", { "rev": "vim9" }) ``` - -Requirements --------------------------------------------------- +## Requirements Vim 8.2+ or Neovim nightly