From cab9ab7b8765ac7e85965a8abf97e4a6d3fa5ac0 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Tue, 21 Apr 2015 13:56:07 +0800 Subject: [PATCH] Easy-align --- assets/style.css | 19 ++++++++ vim-easyalign.md | 115 +++++++++++++++++++++++++++++++++++++++++++++++ vim-help.md | 113 ++++++++++++++++++++++++++++++++++++++++++++++ vim.md | 17 ++++++- 4 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 vim-easyalign.md create mode 100644 vim-help.md diff --git a/assets/style.css b/assets/style.css index 4c3c08941..f45527dbc 100644 --- a/assets/style.css +++ b/assets/style.css @@ -186,3 +186,22 @@ pre.light { pre + pre { margin-top: -1.7em; } + +.key-codes code { + background: #fdfdff; + padding: 3px 8px 3px 8px; + border-radius: 3px; + box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); + margin: 0 5px; +} + +.key-codes code + code { + margin-left: 0; +} + +.key-codes pre code { + background: transparent; + padding: 0; + box-shadow: none; + margin: 0; +} diff --git a/vim-easyalign.md b/vim-easyalign.md new file mode 100644 index 000000000..c29dc5548 --- /dev/null +++ b/vim-easyalign.md @@ -0,0 +1,115 @@ +--- +title: Vim Easyalign +html_class: key-codes +--- + +### [vim-easy-align](https://github.com/junegunn/vim-easy-align) +This plugin allows you to align things. + +| `{Visual}` `⏎` | activate for selection | +| `ga` `{motion}` | activate for motion/text object | +{:.greycode} + +After activating, press a delimiter key. Available delimeters are:
+`` `=` `:` `.` `,` `&` `#` `|` + +## Example + +``` +a = foo +pi = 3.1415 +hello = 'world' +``` + +Press `vip ⏎` or `gaip` to activate via *ip* (inner paragraph). Then press `=` + +``` +a = foo +pi = 3.1415 +hello = 'world' +``` + +## Useful delimiters + +### Variable assignments +`gaip` `=` will align 1st occurence of equal sign + +```js +var one = 1; +var three = 3; +``` + +### JSON or YAML +`gaip` `:` will align 1st occurence of colon + +```yaml +url: jdbc:mysql://localhost/test +database: test +``` + +### Markdown tables +`*|` Align all table delimeters + +```nohighlight +| `` | right align | +| `1` | on 1st occurence | +| `2` | on 2nd occurence (and so on) | +``` + +### Ruby or Python comments +`#` Align comments + +``` +let x = true # one +let y = false # two +let z = "abcdef" # three +``` + +## Modifiers + +| `1` | on 1st occurence (default) | +| `2` | on 2nd occurence | +| `3` | on 3rd occurence (and so on) | +| `*` | on all occurences | +| `-` | on last occurence | +| `-2` | on 2nd to the last occurence | + +You may type modifiers before a delimiter. Example: `gaip` `*|` will align all `|` delimiters. + +## Alignment + +| `⏎` | change alignment align | + +**Example:** `gaip` `⏎` `=` right aligns whatever is before the first delimeter (equal sign). + +``` +express = require('express') + xtend = require('xtend') + pip = require('pip') +``` + +**Example:** `gaip` `⏎` `2|` right aligns the 1st Markdown table column (ie, before the 2nd delimiter). + +``` +| apple | $ 20 | +| orange | $ 42 | +| pineapple | $ 11 | +``` + +## Margins + +| `` `4 ⏎` | Set `left_margin` (to the left of the delimeter) | +| `` `4 ⏎` | Set `right_margin` | +| `↓` | no margin | + +**Example**: `gaip` `` `8⏎` `=` puts 8 spaces before the equal sign + +``` +var x = "one" +var xyz = "two" +``` + +## See also + +* [Examples](https://github.com/junegunn/vim-easy-align#examples) +* [Alignment options](https://github.com/junegunn/vim-easy-align#alignment-options) diff --git a/vim-help.md b/vim-help.md new file mode 100644 index 000000000..870531542 --- /dev/null +++ b/vim-help.md @@ -0,0 +1,113 @@ +--- +title: Vim helpfiles +--- + +``` +:help help-writing +``` +{:.light} + +### Creating a document +Use `help` to preview it, and `text` to edit it. + +```nohighlight +:e doc/potion.txt +:set ft=help +:set ft=text +``` + +### Tags + + * Tags are created with asterisks, eg, `*potion-usage*` + * Links to tags are `|potion-usage|` + * Press `^]` to jump to a tag + +## Syntax reference + +| `*tags*` | Tags | +| `INTRO *tag*` | Section header | +| `|link-to-tags|` | Links to tags (eg, `|:command|`) | +| `'vimoption'` | Vim option (eg, `'textwidth'`) | +| `{code-text}` | Code text (eg, `{Visual}gf`) | +| `[code-text]` | Code text (eg, `[xyz]`) | +| `` | Code text (eg, ``) | +| `` `command` `` | Code text (eg, `cmd`) | +| `CTRL-X` | Code text | +| `www.url.com` | Web URL | +| `Column heading~` | Highlighting | +| `=====` | Separator | +| `-----` | Separator | +{:.greycode} + +### Code blocks +Surround with `>` and `<` characters + +``` +Example: > + xyz +< +``` + +### File header +It's customary to start a file with a tag of the filename, plus a description + +``` +*potion.txt* functionality for the potion programming language +``` + +### Heading +Starts with `ALL CAPS`, ends with `*a-tag*` + +``` +============================================================================== +CONTENTS *potion-contents* +``` + +### Notes +Using `*Todo` and `*Error` will highlight your notes. + +``` + *Todo something to do + *Error something wrong +``` + +### Final modeline + +```nohighlight +vim:tw=78:ts=8:ft=help:norl: +``` + +## Conventions + +### Table of contents + +```nohighlight +|rails-introduction| Introduction and Feature Summary +|rails-commands| General Commands +|rails-navigation| Navigation +``` + +```nohighlight + 1.Intro...................................|ergonomic| + 2.Note to use..............................|CAPSLOCK| + 3.Insert Mode Remappings............|ergonomicInsert| +``` + +### Author lines + +```nohighlight +Author: Jack Hackness *xyz-author* +License: Same terms as Vim itself (see |license|) +``` + +### Command reference + + +```nohighlight +:Ack[!] [options] {pattern} [{directory}] *:Ack* + + Search recursively in {directory} (which defaults to the current + directory) for the {pattern}. Behaves just like the |:grep| command, but + will open the |Quickfix| window for you. If [!] is not given the first + occurence is jumped to. +``` diff --git a/vim.md b/vim.md index 8d5a2bd5b..7d4965a88 100644 --- a/vim.md +++ b/vim.md @@ -1,8 +1,14 @@ ----function +--- title: vim layout: default --- + * [Digraphs](vim-digraphs.html) + * [Help text](vim-help.html) + * [Vimscript](vimscript.html) + * [Vim-unite](vim-unite.html) + * [Vim-easyalign](vim-easyalign.html) + Command line ------------ @@ -116,6 +122,15 @@ Marks `. # Last change `` # Last jump +Text alignment +-------------- + +See `:help formatting` + + :center [width] + :right [width] + :left + ### Calculator (Insert mode) =128/2