Update 2024-02-14 07:51 OpenBSD/amd64-x13

This commit is contained in:
c0dev0id
2024-02-14 07:54:31 +01:00
parent b55e6a3616
commit 9624895938
373 changed files with 19074 additions and 3045 deletions

View File

@@ -1,96 +0,0 @@
autotag.vim
============
If you use ctags to make tags files of your source, it's nice to be able to re-run ctags on a source file when you save it.
However, using `ctags -a` will only change existing entries in a tags file or add new ones. It doesn't delete entries that no longer exist. Should you delete an entity from your source file that's represented by an entry in a tags file, that entry will remain after calling `ctags -a`.
This python function will do two things:
1) It will search for a tags file starting in the directory where your source file resides and moving up a directory at a time until it either finds one or runs out of directories to try.
2) Should it find a tags file, it will then delete all entries in said tags file referencing the source file you've just saved and then execute `ctags -a` on that source file using the relative path to the source file from the tags file.
This way, every time you save a file, your tags file will be seamlessly updated.
Installation
------------
Currently I suggest you use Vundle and install as a normal Bundle
From the Vim command-line
:BundleInstall 'craigemery/vim-autotag'
And add to your ~/.vimrc
Bundle 'craigemery/vim-autotag'
Or you can manually install
cd
git clone git://github.com/craigemery/vim-autotag.git
cd ~/.vim/
mkdir -p plugin
cp ~/vim-autotag.git/plugin/* plugin/
### Install as a Pathogen bundle
```
git clone git://github.com/craigemery/vim-autotag.git ~/.vim/bundle/vim-autotag
```
Getting round other ctags limitations
-------------------------------------
ctags is very file name suffix driven. When the file has no suffix, ctags can fail to detect the file type.
The easiest way to replicate this is when using a #! shebang. I've seen "#!/usr/bin/env python3" in a
shebang not get detected by ctags.
But Vim is better at this. So Vim's filetype buffer setting can help.
So when the buffer being written has no suffix to the file name then the Vim filetype value will be used instead.
So far I've only implemented "python" as one that is given to ctags --language-force=<here> as is.
Other filetypes could be mapped. There's a dict in the AutTag class.
To not map a filetype to a forced language kind, add the vim file type to the comma "," separated
list in autotagExcludeFiletypes.
Configuration
-------------
Autotag can be configured using the following global variables:
| Name | Purpose |
| ---- | ------- |
| `g:autotagExcludeSuffixes` | suffixes to not ctags on |
| `g:autotagExcludeFiletypes` | filetypes to not try & force a language choice on ctags |
| `g:autotagVerbosityLevel` | logging verbosity (as in Python logging module) |
| `g:autotagCtagsCmd` | name of ctags command |
| `g:autotagTagsFile` | name of tags file to look for |
| `g:autotagDisabled` | Disable autotag (enable by setting to any non-blank value) |
| `g:autotagStopAt` | stop looking for a tags file (and make one) at this directory (defaults to $HOME) |
| `g:autotagStartMethod` | Now AutoTag uses Python multiprocessing, the start method is an internal aspect that Python uses.
These can be overridden with buffer specific ones. b: instead of g:
Example:
```
let g:autotagTagsFile=".tags"
```
macOS, Python 3.8 and 'spawn'
-----------------------------
With the release of Python 3.8, the default start method for multiprocessing on macOS has become 'spawn'
At the time of writing there are issues with 'spawn' and I advise making AutoTag ask Python to use 'fork'
i.e. before loading the plugin:
```
let g:autotagStartMethod='fork'
```
Self-Promotion
--------------
Like autotag.vim? Follow the repository on
[GitHub](https://github.com/craigemery/vim-autotag) and vote for it on
[vim.org](http://www.vim.org/scripts/script.php?script_id=1343). And if
you're feeling especially charitable, follow [craigemery] on
[GitHub](https://github.com/craigemery).
License
-------
Copyright (c) Craig Emery. Distributed under the same terms as Vim itself.
See `:help license`.

View File

@@ -1,319 +0,0 @@
"""
(c) Craig Emery 2017-2022
AutoTag.py
"""
from __future__ import print_function
import sys
import os
import fileinput
import logging
from collections import defaultdict
import subprocess
from traceback import format_exc
import multiprocessing as mp
from glob import glob
import vim # pylint: disable=import-error
__all__ = ["autotag"]
# global vim config variables used (all are g:autotag<name>):
# name purpose
# ExcludeSuffixes suffixes to not ctags on
# VerbosityLevel logging verbosity (as in Python logging module)
# CtagsCmd name of ctags command
# TagsFile name of tags file to look for
# Disabled Disable autotag (enable by setting to any non-blank value)
# StopAt stop looking for a tags file (and make one) at this directory (defaults to $HOME)
GLOBALS_DEFAULTS = dict(ExcludeSuffixes="tml.xml.text.txt",
VerbosityLevel=logging.WARNING,
CtagsCmd="ctags",
TagsFile="tags",
TagsDir="",
Disabled=0,
StopAt=0,
StartMethod="")
def do_cmd(cmd, cwd):
""" Abstract subprocess """
with subprocess.Popen(cmd, cwd=cwd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=True) as proc:
stdout = proc.communicate()[0]
return stdout.split("\n")
def vim_global(name, kind=str):
""" Get global variable from vim, cast it appropriately """
ret = GLOBALS_DEFAULTS.get(name, None)
try:
vname = "autotag" + name
v_buffer = "b:" + vname
exists_buffer = (vim.eval(f"exists('{v_buffer}')") == "1")
v_global = "g:" + vname
exists_global = (vim.eval(f"exists('{v_global}')") == "1")
if exists_buffer:
ret = vim.eval(v_buffer)
elif exists_global:
ret = vim.eval(v_global)
else:
if isinstance(ret, int):
vim.command(f"let {v_global}={ret}")
else:
vim.command(f"let {v_global}=\"{ret}\"")
finally:
if kind == bool:
ret = (ret in [1, "1", "true", "yes"])
elif kind == int:
try:
val = int(ret)
except TypeError:
val = ret
except ValueError:
val = ret
ret = val
elif kind == str:
ret = str(ret)
return ret
def init_multiprocessing():
""" Init multiprocessing, set_executable() & get the context we'll use """
wanted_start_method = vim_global("StartMethod") or None
used_start_method = mp.get_start_method()
if wanted_start_method in mp.get_all_start_methods():
used_start_method = wanted_start_method
else:
wanted_start_method = None
# here wanted_start_method is either a valid method or None
# used_start_method is what the module has as the default or our overriden value
ret = mp.get_context(wanted_start_method) # wanted_start_method might be None
try:
mp.set_executable
except AttributeError:
return ret
if used_start_method == 'spawn':
suff = os.path.splitext(sys.executable)[1]
pat1 = f"python*{suff}"
pat2 = os.path.join("bin", pat1)
exes = glob(os.path.join(sys.exec_prefix, pat1)) + glob(os.path.join(sys.exec_prefix, pat2))
if exes:
win = [exe for exe in exes if exe.endswith(f"w{suff}")]
if win:
# In Windows pythonw.exe is best
ret.set_executable(win[0])
else:
# This isn't great, for now pick the first one
ret.set_executable(exes[0])
return ret
CTX = init_multiprocessing()
class VimAppendHandler(logging.Handler):
""" Logger handler that finds a buffer and appends the log message as a new line """
def __init__(self, name):
logging.Handler.__init__(self)
self.__name = name
self.__formatter = logging.Formatter()
def __find_buffer(self):
""" Look for the named buffer """
for buff in vim.buffers:
if buff and buff.name and buff.name.endswith(self.__name):
yield buff
def emit(self, record):
""" Emit the logging message """
for buff in self.__find_buffer():
buff.append(self.__formatter.format(record))
def set_logger_verbosity():
""" Set the verbosity of the logger """
level = vim_global("VerbosityLevel", kind=int)
LOGGER.setLevel(level)
def make_and_add_handler(logger, name):
""" Make the handler and add it to the standard logger """
ret = VimAppendHandler(name)
logger.addHandler(ret)
return ret
try:
LOGGER
except NameError:
DEBUG_NAME = "autotag_debug"
LOGGER = logging.getLogger(DEBUG_NAME)
HANDLER = make_and_add_handler(LOGGER, DEBUG_NAME)
set_logger_verbosity()
class AutoTag(): # pylint: disable=too-many-instance-attributes
""" Class that does auto ctags updating """
LOG = LOGGER
AUTOFILETYPES = ["python"]
FILETYPES = {}
def __init__(self):
self.locks = {}
self.tags = defaultdict(list)
self.excludesuffix = ["." + s for s in vim_global("ExcludeSuffixes").split(".")]
self.excludefiletype = vim_global("ExcludeFiletypes").split(",")
set_logger_verbosity()
self.sep_used_by_ctags = '/'
self.ctags_cmd = vim_global("CtagsCmd")
self.tags_file = str(vim_global("TagsFile"))
self.tags_dir = str(vim_global("TagsDir"))
self.parents = os.pardir * (len(os.path.split(self.tags_dir)) - 1)
self.count = 0
self.stop_at = vim_global("StopAt")
def find_tag_file(self, source):
""" Find the tag file that belongs to the source file """
AutoTag.LOG.info('source = "%s"', source)
(drive, fname) = os.path.splitdrive(source)
ret = None
while ret is None:
fname = os.path.dirname(fname)
AutoTag.LOG.info('drive = "%s", file = "%s"', drive, fname)
tags_dir = os.path.join(drive, fname)
tags_file = os.path.join(tags_dir, self.tags_dir, self.tags_file)
AutoTag.LOG.info('testing tags_file "%s"', tags_file)
if os.path.isfile(tags_file):
stinf = os.stat(tags_file)
if stinf:
size = getattr(stinf, 'st_size', None)
if size is None:
AutoTag.LOG.warning("Could not stat tags file %s", tags_file)
ret = ""
ret = (fname, tags_file)
elif tags_dir and tags_dir == self.stop_at:
AutoTag.LOG.info("Reached %s. Making one %s", self.stop_at, tags_file)
open(tags_file, 'wb').close()
ret = (fname, tags_file)
ret = ""
elif not fname or fname == os.sep or fname == "//" or fname == "\\\\":
AutoTag.LOG.info('bail (file = "%s")', fname)
ret = ""
return ret or None
def add_source(self, source, filetype):
""" Make a note of the source file, ignoring some etc """
if not source:
AutoTag.LOG.warning('No source')
return
if os.path.basename(source) == self.tags_file:
AutoTag.LOG.info("Ignoring tags file %s", self.tags_file)
return
suff = os.path.splitext(source)[1]
if suff:
AutoTag.LOG.info("Source %s has suffix %s, so filetype doesn't count!", source, suff)
filetype = None
else:
AutoTag.LOG.info("Source %s has no suffix, so filetype counts!", source)
if suff in self.excludesuffix:
AutoTag.LOG.info("Ignoring excluded suffix %s for file %s", suff, source)
return
if filetype in self.excludefiletype:
AutoTag.LOG.info("Ignoring excluded filetype %s for file %s", filetype, source)
return
found = self.find_tag_file(source)
if found:
(tags_dir, tags_file) = found
relative_source = os.path.splitdrive(source)[1][len(tags_dir):]
if relative_source[0] == os.sep:
relative_source = relative_source[1:]
if os.sep != self.sep_used_by_ctags:
relative_source = relative_source.replace(os.sep, self.sep_used_by_ctags)
key = (tags_dir, tags_file, filetype)
self.tags[key].append(relative_source)
if key not in self.locks:
self.locks[key] = CTX.Lock()
@staticmethod
def good_tag(line, excluded):
""" Filter method for stripping tags """
if line[0] == '!':
return True
fields = line.split('\t')
AutoTag.LOG.log(1, "read tags line:%s", str(fields))
if len(fields) > 3 and fields[1] not in excluded:
return True
return False
def strip_tags(self, tags_file, sources):
""" Strip all tags for a given source file """
AutoTag.LOG.info("Stripping tags for %s from tags file %s", ",".join(sources), tags_file)
backup = ".SAFE"
try:
with fileinput.FileInput(files=tags_file, inplace=True, backup=backup) as source:
for line in source:
line = line.strip()
if self.good_tag(line, sources):
print(line)
finally:
try:
os.unlink(tags_file + backup)
except IOError:
pass
def _vim_ft_to_ctags_ft(self, name):
""" convert vim filetype strings to ctags strings """
if name in AutoTag.AUTOFILETYPES:
return name
return self.FILETYPES.get(name, None)
def update_tags_file(self, key, sources):
""" Strip all tags for the source file, then re-run ctags in append mode """
(tags_dir, tags_file, filetype) = key
lock = self.locks[key]
if self.tags_dir:
sources = [os.path.join(self.parents + s) for s in sources]
cmd = [self.ctags_cmd]
if self.tags_file:
cmd += ["-f", self.tags_file]
if filetype:
ctags_filetype = self._vim_ft_to_ctags_ft(filetype)
if ctags_filetype:
cmd += [f"--language-force={ctags_filetype}"]
cmd += ["-a"]
def is_file(src):
""" inner """
return os.path.isfile(os.path.join(tags_dir, self.tags_dir, src))
srcs = list(filter(is_file, sources))
if not srcs:
return
cmd += [f'"{s}"' for s in srcs]
cmd = " ".join(cmd)
with lock:
self.strip_tags(tags_file, sources)
AutoTag.LOG.log(1, "%s: %s", tags_dir, cmd)
for line in do_cmd(cmd, self.tags_dir or tags_dir):
AutoTag.LOG.log(10, line)
def rebuild_tag_files(self):
""" rebuild the tags file thread worker """
for (key, sources) in self.tags.items():
AutoTag.LOG.info('Process(%s, %s)', key, ",".join(sources))
proc = CTX.Process(target=self.update_tags_file, args=(key, sources))
proc.daemon = True
proc.start()
def autotag():
""" Do the work """
try:
if not vim_global("Disabled", bool):
runner = AutoTag()
runner.add_source(vim.eval("expand(\"%:p\")"), vim.eval("&ft"))
runner.rebuild_tag_files()
except Exception: # pylint: disable=broad-except
logging.warning(format_exc())

View File

@@ -1,16 +0,0 @@
if ! has("python3")
finish
endif
python3 import sys, os, vim
python3 sys.path.insert(0, os.path.dirname(vim.eval('expand("<sfile>")')))
python3 import autotag
function! autotag#Run()
if exists("b:netrw_method")
return
endif
python3 autotag.autotag()
if exists(":TlistUpdate")
TlistUpdate
endif
endfunction

View File

@@ -1,39 +0,0 @@
"
" (c) Craig Emery 2017-2022
"
" Increment the number below for a dynamic #include guard
let s:autotag_vim_version=1
if exists("g:autotag_vim_version_sourced")
if s:autotag_vim_version == g:autotag_vim_version_sourced
finish
endif
endif
let g:autotag_vim_version_sourced=s:autotag_vim_version
" This file supplies automatic tag regeneration when saving files
" There's a problem with ctags when run with -a (append)
" ctags doesn't remove entries for the supplied source file that no longer exist
" so this script (implemented in Python) finds a tags file for the file vim has
" just saved, removes all entries for that source file and *then* runs ctags -a
if !has("python3")
finish
endif " !has("python3")
function! AutoTagDebug()
new
file autotag_debug
setlocal buftype=nowrite
setlocal bufhidden=delete
setlocal noswapfile
normal 
endfunction
augroup autotag
au!
autocmd BufWritePost,FileWritePost * call autotag#Run ()
augroup END
" vim:shiftwidth=3:ts=3

File diff suppressed because it is too large Load Diff

View File

@@ -1,891 +0,0 @@
easy-align.txt easy-align Last change: December 14 2014
EASY-ALIGN - TABLE OF CONTENTS *easyalign* *easy-align* *easy-align-toc*
==============================================================================
vim-easy-align
Demo |easy-align-1|
Features |easy-align-2|
Installation |easy-align-3|
TLDR - One-minute guide |easy-align-4|
Usage |easy-align-5|
Concept of alignment rule |easy-align-5-1|
Execution models |easy-align-5-2|
1. Using <Plug> mappings |easy-align-5-2-1|
2. Using :EasyAlign command |easy-align-5-2-2|
Interactive mode |easy-align-5-3|
Predefined alignment rules |easy-align-5-3-1|
Examples |easy-align-5-3-2|
Using regular expressions |easy-align-5-3-3|
Alignment options in interactive mode |easy-align-5-3-4|
Live interactive mode |easy-align-5-4|
Non-interactive mode |easy-align-5-5|
Partial alignment in blockwise-visual mode |easy-align-5-6|
Alignment options |easy-align-6|
List of options |easy-align-6-1|
Filtering lines |easy-align-6-2|
Examples |easy-align-6-2-1|
Ignoring delimiters in comments or strings |easy-align-6-3|
Ignoring unmatched lines |easy-align-6-4|
Aligning delimiters of different lengths |easy-align-6-5|
Adjusting indentation |easy-align-6-6|
Alignments over multiple occurrences of delimiters |easy-align-6-7|
Extending alignment rules |easy-align-6-8|
Examples |easy-align-6-8-1|
Other options |easy-align-7|
Disabling &foldmethod during alignment |easy-align-7-1|
Left/right/center mode switch in interactive mode |easy-align-7-2|
Advanced examples and use cases |easy-align-8|
Related work |easy-align-9|
Author |easy-align-10|
License |easy-align-11|
VIM-EASY-ALIGN *vim-easy-align*
==============================================================================
A simple, easy-to-use Vim alignment plugin.
*easy-align-1*
DEMO *easy-align-demo*
==============================================================================
Screencast:
https://raw.githubusercontent.com/junegunn/i/master/vim-easy-align.gif
(Too fast? Slower GIF is {here}{1})
{1} https://raw.githubusercontent.com/junegunn/i/master/vim-easy-align-slow.gif
*easy-align-2*
FEATURES *easy-align-features*
==============================================================================
- Easy to use
- Comes with a predefined set of alignment rules
- Provides a fast and intuitive interface
- Extensible
- You can define your own rules
- Supports arbitrary regular expressions
- Optimized for code editing
- Takes advantage of syntax highlighting feature to avoid unwanted
alignments
*easy-align-3*
INSTALLATION *easy-align-installation*
==============================================================================
Use your favorite plugin manager.
Using {vim-plug}{2}:
>
Plug 'junegunn/vim-easy-align'
<
{2} https://github.com/junegunn/vim-plug
*easy-align-4*
TLDR - ONE-MINUTE GUIDE *easy-align-tldr-one-minute-guide*
==============================================================================
Add the following mappings to your .vimrc.
*<Plug>(EasyAlign)*
>
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
<
And with the following lines of text,
>
apple =red
grass+=green
sky-= blue
<
try these commands:
- vip<Enter>=
- `v`isual-select `i`nner `p`aragraph
- Start EasyAlign command (<Enter>)
- Align around `=`
- `gaip=`
- Start EasyAlign command (`ga`) for `i`nner `p`aragraph
- Align around `=`
Notice that the commands are repeatable with `.` key if you have installed
{repeat.vim}{3}. Install {visualrepeat}{4} as well if you want to repeat in
visual mode.
{3} https://github.com/tpope/vim-repeat
{4} https://github.com/vim-scripts/visualrepeat
*easy-align-5*
USAGE *easy-align-usage*
==============================================================================
< Concept of alignment rule >_________________________________________________~
*easy-align-concept-of-alignment-rule*
*easy-align-5-1*
Though easy-align can align lines of text around any delimiter, it provides
shortcuts for the most common use cases with the concept of "alignment rule".
An alignment rule is a predefined set of options for common alignment tasks,
which is identified by a single character, DELIMITER KEY, such as <Space>,
`=`, `:`, `.`, `|`, `&`, `#`, and `,`.
Think of it as a shortcut. Instead of writing regular expression and setting
several options, you can just type in a single character.
< Execution models >__________________________________________________________~
*easy-align-execution-models*
*easy-align-5-2*
There are two ways to use easy-align.
1. Using <Plug> mappings~
*easy-align-1-using-plug-mappings*
*easy-align-5-2-1*
The recommended method is to use <Plug> mappings as described earlier.
*<Plug>(LiveEasyAlign)*
----------------------+--------+-----------------------------------------------------
Mapping | Mode | Description ~
----------------------+--------+-----------------------------------------------------
<Plug>(EasyAlign) | normal | Start interactive mode for a motion/text object
<Plug>(EasyAlign) | visual | Start interactive mode for the selection
<Plug>(LiveEasyAlign) | normal | Start live-interactive mode for a motion/text object
<Plug>(LiveEasyAlign) | visual | Start live-interactive mode for the selection
----------------------+--------+-----------------------------------------------------
2. Using :EasyAlign command~
*easy-align-2-using-easyalign-command*
*easy-align-5-2-2*
*:EasyAlign*
If you prefer command-line or do not want to start interactive mode, you can
use `:EasyAlign` command instead.
*:LiveEasyAlign*
-------------------------------------------+-----------------------------------------------
Mode | Command ~
-------------------------------------------+-----------------------------------------------
Interactive mode | `:EasyAlign[!] [OPTIONS]`
Live interactive mode | `:LiveEasyAlign[!] [...]`
Non-interactive mode (predefined rules) | `:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]`
Non-interactive mode (regular expressions) | `:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]`
-------------------------------------------+-----------------------------------------------
< Interactive mode >__________________________________________________________~
*easy-align-interactive-mode*
*easy-align-5-3*
The following sections will assume that you have <Plug>(EasyAlign) mappings in
your .vimrc as below:
>
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
<
With these mappings, you can align text with only a few keystrokes.
1. <Enter> key in visual mode, or `ga` followed by a motion or a text object to
start interactive mode
2. Optional: Enter keys to select alignment mode (left, right, or center)
3. Optional: N-th delimiter (default: 1)
- `1` Around the 1st occurrences of delimiters
- `2` Around the 2nd occurrences of delimiters
- ...
- `*` Around all occurrences of delimiters
- `**` Left-right alternating alignment around all delimiters
- `-` Around the last occurrences of delimiters (`-1`)
- `-2` Around the second to last occurrences of delimiters
- ...
4. Delimiter key (a single keystroke; <Space>, `=`, `:`, `.`, `|`, `&`, `#`, `,`)
Predefined alignment rules~
*easy-align-predefined-alignment-rules*
*easy-align-5-3-1*
--------------+--------------------------------------------------------------------
Delimiter key | Description/Use cases ~
--------------+--------------------------------------------------------------------
<Space> | General alignment around whitespaces
`=` | Operators containing equals sign ( `=` , `==,` `!=` , `+=` , `&&=` , ...)
`:` | Suitable for formatting JSON or YAML
`.` | Multi-line method chaining
`,` | Multi-line method arguments
`&` | LaTeX tables (matches `&` and `\\` )
`#` | Ruby/Python comments
`"` | Vim comments
<Bar> | Table markdown
--------------+--------------------------------------------------------------------
*g:easy_align_delimiters*
You can override these default rules or define your own rules with
`g:easy_align_delimiters`, which will be described in {the later section}{5}.
{5} https://github.com/junegunn/vim-easy-align#extending-alignment-rules
Examples~
*easy-align-examples*
*easy-align-5-3-2*
------------------+------------------------------------+--------------------
With visual map | Description | Equivalent command ~
------------------+------------------------------------+--------------------
<Enter><Space> | Around 1st whitespaces | :'<,'>EasyAlign\
<Enter>2<Space> | Around 2nd whitespaces | :'<,'>EasyAlign2\
<Enter>-<Space> | Around the last whitespaces | :'<,'>EasyAlign-\
<Enter>-2<Space> | Around the 2nd to last whitespaces | :'<,'>EasyAlign-2\
<Enter>: | Around 1st colon ( `key: value` ) | :'<,'>EasyAlign:
<Enter><Right>: | Around 1st colon ( `key : value` ) | :'<,'>EasyAlign:<l1
<Enter>= | Around 1st operators with = | :'<,'>EasyAlign=
<Enter>3= | Around 3rd operators with = | :'<,'>EasyAlign3=
<Enter>*= | Around all operators with = | :'<,'>EasyAlign*=
<Enter>**= | Left-right alternating around = | :'<,'>EasyAlign**=
<Enter><Enter>= | Right alignment around 1st = | :'<,'>EasyAlign!=
<Enter><Enter>**= | Right-left alternating around = | :'<,'>EasyAlign!**=
------------------+------------------------------------+--------------------
Using regular expressions~
*easy-align-using-regular-expressions*
*easy-align-5-3-3*
Instead of finishing the command with a predefined delimiter key, you can type
in a regular expression after CTRL-/ or CTRL-X key. For example, if you want
to align text around all occurrences of numbers:
- <Enter>
- `*`
- CTRL-X
- `[0-9]\+`
Alignment options in interactive mode~
*easy-align-alignment-options-in-interactive-mode*
*easy-align-5-3-4*
While in interactive mode, you can set alignment options using special
shortcut keys listed below. The meaning of each option will be described in
{the following sections}{6}.
--------+--------------------+---------------------------------------------------
Key | Option | Values ~
--------+--------------------+---------------------------------------------------
CTRL-F | `filter` | Input string ( `[gv]/.*/?` )
CTRL-I | `indentation` | shallow, deep, none, keep
CTRL-L | `left_margin` | Input number or string
CTRL-R | `right_margin` | Input number or string
CTRL-D | `delimiter_align` | left, center, right
CTRL-U | `ignore_unmatched` | 0, 1
CTRL-G | `ignore_groups` | [], ["String'], ["Comment'], ["String', "Comment']
CTRL-A | `align` | Input string ( `/[lrc]+\*{0,2}/` )
<Left> | `stick_to_left` | `{ 'stick_to_left': 1, 'left_margin': 0 }`
<Right> | `stick_to_left` | `{ 'stick_to_left': 0, 'left_margin': 1 }`
<Down> | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }`
--------+--------------------+---------------------------------------------------
{6} https://github.com/junegunn/vim-easy-align#alignment-options
< Live interactive mode >_____________________________________________________~
*easy-align-live-interactive-mode*
*easy-align-5-4*
If you're performing a complex alignment where multiple options should be
carefully adjusted, try "live interactive mode" where you can preview the
result of the alignment on-the-fly as you type in.
Live interactive mode can be started with either <Plug>(LiveEasyAlign) map or
`:LiveEasyAlign` command. Or you can switch to live interactive mode while in
ordinary interactive mode by pressing CTRL-P. (P for Preview)
In live interactive mode, you have to type in the same delimiter (or CTRL-X on
regular expression) again to finalize the alignment. This allows you to
preview the result of the alignment and freely change the delimiter using
backspace key without leaving the interactive mode.
< Non-interactive mode >______________________________________________________~
*easy-align-non-interactive-mode*
*easy-align-5-5*
Instead of starting interactive mode, you can use declarative, non-interactive
`:EasyAlign` command.
>
" Using predefined alignment rules
" :EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
:EasyAlign :
:EasyAlign =
:EasyAlign *=
:EasyAlign 3\
" Using arbitrary regular expressions
" :EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
:EasyAlign /[:;]\+/
:EasyAlign 2/[:;]\+/
:EasyAlign */[:;]\+/
:EasyAlign **/[:;]\+/
<
A command can end with alignment options, {each of which will be discussed in
detail later}{6}, in Vim dictionary format.
- `:EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': 0 }`
`stick_to_left` of 1 means that the matched delimiter should be positioned
right next to the preceding token, and `left_margin` of 0 removes the margin
on the left. So we get:
>
apple;: banana:: cake
data;; exchange:; format
<
Option names are fuzzy-matched, so you can write as follows:
- `:EasyAlign * /[:;]\+/ { 'stl': 1, 'l': 0 }`
You can even omit spaces between the arguments, so concisely (or cryptically):
- `:EasyAlign*/[:;]\+/{'s':1,'l':0}`
Nice. But let's make it even shorter. Option values can be written in
shorthand notation.
- `:EasyAlign*/[:;]\+/<l0`
The following table summarizes the shorthand notation.
-------------------+-----------
Option | Expression~
-------------------+-----------
`filter` | `[gv]/.*/`
`left_margin` | `l[0-9]+`
`right_margin` | `r[0-9]+`
`stick_to_left` | `<` or `>`
`ignore_unmatched` | `iu[01]`
`ignore_groups` | `ig\[.*\]`
`align` | `a[lrc*]*`
`delimiter_align` | `d[lrc]`
`indentation` | `i[ksdn]`
-------------------+-----------
For your information, the same operation can be done in interactive mode as
follows:
- <Enter>
- `*`
- <Left>
- CTRL-X
- `[:;]\+`
{6} https://github.com/junegunn/vim-easy-align#alignment-options
< Partial alignment in blockwise-visual mode >________________________________~
*easy-align-partial-alignment-in-blockwise-visual-mode*
*easy-align-5-6*
In blockwise-visual mode (CTRL-V), EasyAlign command aligns only the selected
text in the block, instead of the whole lines in the range.
Consider the following case where you want to align text around `=>`
operators.
>
my_hash = { :a => 1,
:aa => 2,
:aaa => 3 }
<
In non-blockwise visual mode (`v` / `V`), <Enter>= won't work since the
assignment operator in the first line gets in the way. So we instead enter
blockwise-visual mode (CTRL-V), and select the text around`=>` operators, then
press <Enter>=.
>
my_hash = { :a => 1,
:aa => 2,
:aaa => 3 }
<
However, in this case, we don't really need blockwise visual mode since the
same can be easily done using the negative N-th parameter: <Enter>-=
*easy-align-6*
ALIGNMENT OPTIONS *easy-align-alignment-options*
==============================================================================
< List of options >___________________________________________________________~
*easy-align-list-of-options*
*easy-align-6-1*
-------------------+---------+-----------------------+--------------------------------------------------------
Option | Type | Default | Description ~
-------------------+---------+-----------------------+--------------------------------------------------------
`filter` | string | | Line filtering expression: `g/../` or `v/../`
`left_margin` | number | 1 | Number of spaces to attach before delimiter
`left_margin` | string | `' '` | String to attach before delimiter
`right_margin` | number | 1 | Number of spaces to attach after delimiter
`right_margin` | string | `' '` | String to attach after delimiter
`stick_to_left` | boolean | 0 | Whether to position delimiter on the left-side
`ignore_groups` | list | ["String', "Comment'] | Delimiters in these syntax highlight groups are ignored
`ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter
`indentation` | string | `k` | Indentation method (keep, deep, shallow, none)
`delimiter_align` | string | `r` | Determines how to align delimiters of different lengths
`align` | string | `l` | Alignment modes for multiple occurrences of delimiters
-------------------+---------+-----------------------+--------------------------------------------------------
There are 4 ways to set alignment options (from lowest precedence to highest):
1. Some option values can be set with corresponding global variables
2. Option values can be specified in the definition of each alignment rule
3. Option values can be given as arguments to `:EasyAlign` command
4. Option values can be set in interactive mode using special shortcut keys
*g:easy_align_ignore_groups* *g:easy_align_ignore_unmatched*
*g:easy_align_indentation* *g:easy_align_delimiter_align*
-------------------+-----------------+-------------+--------------------------------
Option name | Shortcut key | Abbreviated | Global variable ~
-------------------+-----------------+-------------+--------------------------------
`filter` | CTRL-F | `[gv]/.*/` |
`left_margin` | CTRL-L | `l[0-9]+` |
`right_margin` | CTRL-R | `r[0-9]+` |
`stick_to_left` | <Left>, <Right> | `<` or `>` |
`ignore_groups` | CTRL-G | `ig\[.*\]` | `g:easy_align_ignore_groups`
`ignore_unmatched` | CTRL-U | `iu[01]` | `g:easy_align_ignore_unmatched`
`indentation` | CTRL-I | `i[ksdn]` | `g:easy_align_indentation`
`delimiter_align` | CTRL-D | `d[lrc]` | `g:easy_align_delimiter_align`
`align` | CTRL-A | `a[lrc*]*` |
-------------------+-----------------+-------------+--------------------------------
< Filtering lines >___________________________________________________________~
*easy-align-filtering-lines*
*easy-align-6-2*
With `filter` option, you can align lines that only match or do not match a
given pattern. There are several ways to set the pattern.
1. Press CTRL-F in interactive mode and type in `g/pat/` or `v/pat/`
2. In command-line, it can be written in dictionary format: `{'filter':
'g/pat/'}`
3. Or in shorthand notation: `g/pat/` or `v/pat/`
(You don't need to escape "/'s in the regular expression)
Examples~
*easy-align-6-2-1*
>
" Start interactive mode with filter option set to g/hello/
EasyAlign g/hello/
" Start live interactive mode with filter option set to v/goodbye/
LiveEasyAlign v/goodbye/
" Align the lines with 'hi' around the first colons
EasyAlign:g/hi/
<
< Ignoring delimiters in comments or strings >________________________________~
*easy-align-ignoring-delimiters-in-comments-or-strings*
*easy-align-6-3*
EasyAlign can be configured to ignore delimiters in certain syntax highlight
groups, such as code comments or strings. By default, delimiters that are
highlighted as code comments or strings are ignored.
>
" Default:
" If a delimiter is in a highlight group whose name matches
" any of the followings, it will be ignored.
let g:easy_align_ignore_groups = ['Comment', 'String']
<
For example, the following paragraph
>
{
# Quantity of apples: 1
apple: 1,
# Quantity of bananas: 2
bananas: 2,
# Quantity of grape:fruits: 3
'grape:fruits': 3
}
<
becomes as follows on <Enter>: (or `:EasyAlign:`)
>
{
# Quantity of apples: 1
apple: 1,
# Quantity of bananas: 2
bananas: 2,
# Quantity of grape:fruits: 3
'grape:fruits': 3
}
<
Naturally, this feature only works when syntax highlighting is enabled.
You can change the default rule by using one of these 4 methods.
1. Press CTRL-G in interactive mode to switch groups
2. Define global `g:easy_align_ignore_groups` list
3. Define a custom rule in `g:easy_align_delimiters` with `ignore_groups` option
4. Provide `ignore_groups` option to `:EasyAlign` command. e.g. `:EasyAlign:ig[]`
For example if you set `ignore_groups` option to be an empty list, you get
>
{
# Quantity of apples: 1
apple: 1,
# Quantity of bananas: 2
bananas: 2,
# Quantity of grape: fruits: 3
'grape: fruits': 3
}
<
If a pattern in `ignore_groups` is prepended by a `!`, it will have the
opposite meaning. For instance, if `ignore_groups` is given as `['!Comment']`,
delimiters that are not highlighted as Comment will be ignored during the
alignment.
< Ignoring unmatched lines >__________________________________________________~
*easy-align-ignoring-unmatched-lines*
*easy-align-6-4*
`ignore_unmatched` option determines how EasyAlign command processes lines
that do not have N-th delimiter.
1. In left-alignment mode, they are ignored
2. In right or center-alignment mode, they are not ignored, and the last tokens
from those lines are aligned as well as if there is an invisible trailing
delimiter at the end of each line
3. If `ignore_unmatched` is 1, they are ignored regardless of the alignment mode
4. If `ignore_unmatched` is 0, they are not ignored regardless of the mode
Let's take an example. When we align the following code block around the (1st)
colons,
>
{
apple: proc {
this_line_does_not_have_a_colon
},
bananas: 2,
grapefruits: 3
}
<
this is usually what we want.
>
{
apple: proc {
this_line_does_not_have_a_colon
},
bananas: 2,
grapefruits: 3
}
<
However, we can override this default behavior by setting `ignore_unmatched`
option to zero using one of the following methods.
1. Press CTRL-U in interactive mode to toggle `ignore_unmatched` option
2. Set the global `g:easy_align_ignore_unmatched` variable to 0
3. Define a custom alignment rule with `ignore_unmatched` option set to 0
4. Provide `ignore_unmatched` option to `:EasyAlign` command. e.g.
`:EasyAlign:iu0`
Then we get,
>
{
apple: proc {
this_line_does_not_have_a_colon
},
bananas: 2,
grapefruits: 3
}
<
< Aligning delimiters of different lengths >__________________________________~
*easy-align-aligning-delimiters-of-different-lengths*
*easy-align-6-5*
Global `g:easy_align_delimiter_align` option and rule-wise/command-wise
`delimiter_align` option determines how matched delimiters of different
lengths are aligned.
>
apple = 1
banana += apple
cake ||= banana
<
By default, delimiters are right-aligned as follows.
>
apple = 1
banana += apple
cake ||= banana
<
However, with `:EasyAlign=dl`, delimiters are left-aligned.
>
apple = 1
banana += apple
cake ||= banana
<
And on `:EasyAlign=dc`, center-aligned.
>
apple = 1
banana += apple
cake ||= banana
<
In interactive mode, you can change the option value with CTRL-D key.
< Adjusting indentation >_____________________________________________________~
*easy-align-adjusting-indentation*
*easy-align-6-6*
By default :EasyAlign command keeps the original indentation of the lines. But
then again we have `indentation` option. See the following example.
>
# Lines with different indentation
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Default: _k_eep the original indentation
# :EasyAlign=
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Use the _s_hallowest indentation among the lines
# :EasyAlign=is
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Use the _d_eepest indentation among the lines
# :EasyAlign=id
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Indentation: _n_one
# :EasyAlign=in
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
<
In interactive mode, you can change the option value with CTRL-I key.
< Alignments over multiple occurrences of delimiters >________________________~
*easy-align-alignments-over-multiple-occurrences-of-delimiters*
*easy-align-6-7*
As stated above, "N-th" parameter is used to target specific occurrences of
the delimiter when it appears multiple times in each line.
To recap:
>
" Left-alignment around the FIRST occurrences of delimiters
:EasyAlign =
" Left-alignment around the SECOND occurrences of delimiters
:EasyAlign 2=
" Left-alignment around the LAST occurrences of delimiters
:EasyAlign -=
" Left-alignment around ALL occurrences of delimiters
:EasyAlign *=
" Left-right ALTERNATING alignment around all occurrences of delimiters
:EasyAlign **=
" Right-left ALTERNATING alignment around all occurrences of delimiters
:EasyAlign! **=
<
In addition to these, you can fine-tune alignments over multiple occurrences
of the delimiters with "align' option. (The option can also be set in
interactive mode with the special key CTRL-A)
>
" Left alignment over the first two occurrences of delimiters
:EasyAlign = { 'align': 'll' }
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
:EasyAlign = { 'a': 'rlc' }
" Using shorthand notation
:EasyAlign = arlc
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
:EasyAlign 2=arlc
" (*) Repeating alignments (default: l, r, or c)
" Right, left, center, center, center, center, ...
:EasyAlign *=arlc
" (**) Alternating alignments (default: lr or rl)
" Right, left, center, right, left, center, ...
:EasyAlign **=arlc
" Right, left, center, center, center, ... repeating alignment
" over the 3rd to the last occurrences of delimiters
:EasyAlign 3=arlc*
" Right, left, center, right, left, center, ... alternating alignment
" over the 3rd to the last occurrences of delimiters
:EasyAlign 3=arlc**
<
< Extending alignment rules >_________________________________________________~
*easy-align-extending-alignment-rules*
*easy-align-6-8*
Although the default rules should cover the most of the use cases, you can
extend the rules by setting a dictionary named `g:easy_align_delimiters`.
You may refer to the definitions of the default alignment rules {here}{7}.
{7} https://github.com/junegunn/vim-easy-align/blob/2.9.6/autoload/easy_align.vim#L32-L46
Examples~
*easy-align-6-8-1*
>
let g:easy_align_delimiters = {
\ '>': { 'pattern': '>>\|=>\|>' },
\ '/': {
\ 'pattern': '//\+\|/\*\|\*/',
\ 'delimiter_align': 'l',
\ 'ignore_groups': ['!Comment'] },
\ ']': {
\ 'pattern': '[[\]]',
\ 'left_margin': 0,
\ 'right_margin': 0,
\ 'stick_to_left': 0
\ },
\ ')': {
\ 'pattern': '[()]',
\ 'left_margin': 0,
\ 'right_margin': 0,
\ 'stick_to_left': 0
\ },
\ 'd': {
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
\ 'left_margin': 0,
\ 'right_margin': 0
\ }
\ }
<
*easy-align-7*
OTHER OPTIONS *easy-align-other-options*
==============================================================================
< Disabling &foldmethod during alignment >____________________________________~
*easy-align-disabling-foldmethod-during-alignment*
*easy-align-7-1*
*g:easy_align_bypass_fold*
{It is reported}{8} that 'foldmethod' value of `expr` or `syntax` can
significantly slow down the alignment when editing a large, complex file with
many folds. To alleviate this issue, EasyAlign provides an option to
temporarily set 'foldmethod' to `manual` during the alignment task. In order
to enable this feature, set `g:easy_align_bypass_fold` switch to 1.
>
let g:easy_align_bypass_fold = 1
<
{8} https://github.com/junegunn/vim-easy-align/issues/14
< Left/right/center mode switch in interactive mode >_________________________~
*easy-align-left-right-center-mode-switch-in-interactive-mode*
*easy-align-7-2*
In interactive mode, you can choose the alignment mode you want by pressing
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
and changes to right and center mode as you press enter keys, while the bang
version first starts in right-alignment mode.
- `:EasyAlign`
- Left, Right, Center
- `:EasyAlign!`
- Right, Left, Center
If you do not prefer this default mode transition, you can define your own
settings as follows.
*g:easy_align_interactive_modes* *g:easy_align_bang_interactive_modes*
>
let g:easy_align_interactive_modes = ['l', 'r']
let g:easy_align_bang_interactive_modes = ['c', 'r']
<
*easy-align-8*
ADVANCED EXAMPLES AND USE CASES *easy-align-advanced-examples-and-use-cases*
==============================================================================
See {EXAMPLES.md}{9} for more examples.
{9} https://github.com/junegunn/vim-easy-align/blob/master/EXAMPLES.md
*easy-align-9*
RELATED WORK *easy-align-related-work*
==============================================================================
- {DrChip's Alignment Tool for Vim}{10}
- {Tabular}{11}
{10} http://www.drchip.org/astronaut/vim/align.html
{11} https://github.com/godlygeek/tabular
*easy-align-10*
AUTHOR *easy-align-author*
==============================================================================
{Junegunn Choi}{12}
{12} https://github.com/junegunn
*easy-align-11*
LICENSE *easy-align-license*
==============================================================================
MIT
==============================================================================
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:

View File

@@ -1,84 +0,0 @@
:EasyAlign easy_align.txt /*:EasyAlign*
:LiveEasyAlign easy_align.txt /*:LiveEasyAlign*
<Plug>(EasyAlign) easy_align.txt /*<Plug>(EasyAlign)*
<Plug>(LiveEasyAlign) easy_align.txt /*<Plug>(LiveEasyAlign)*
easy-align easy_align.txt /*easy-align*
easy-align-1 easy_align.txt /*easy-align-1*
easy-align-1-using-plug-mappings easy_align.txt /*easy-align-1-using-plug-mappings*
easy-align-10 easy_align.txt /*easy-align-10*
easy-align-11 easy_align.txt /*easy-align-11*
easy-align-2 easy_align.txt /*easy-align-2*
easy-align-2-using-easyalign-command easy_align.txt /*easy-align-2-using-easyalign-command*
easy-align-3 easy_align.txt /*easy-align-3*
easy-align-4 easy_align.txt /*easy-align-4*
easy-align-5 easy_align.txt /*easy-align-5*
easy-align-5-1 easy_align.txt /*easy-align-5-1*
easy-align-5-2 easy_align.txt /*easy-align-5-2*
easy-align-5-2-1 easy_align.txt /*easy-align-5-2-1*
easy-align-5-2-2 easy_align.txt /*easy-align-5-2-2*
easy-align-5-3 easy_align.txt /*easy-align-5-3*
easy-align-5-3-1 easy_align.txt /*easy-align-5-3-1*
easy-align-5-3-2 easy_align.txt /*easy-align-5-3-2*
easy-align-5-3-3 easy_align.txt /*easy-align-5-3-3*
easy-align-5-3-4 easy_align.txt /*easy-align-5-3-4*
easy-align-5-4 easy_align.txt /*easy-align-5-4*
easy-align-5-5 easy_align.txt /*easy-align-5-5*
easy-align-5-6 easy_align.txt /*easy-align-5-6*
easy-align-6 easy_align.txt /*easy-align-6*
easy-align-6-1 easy_align.txt /*easy-align-6-1*
easy-align-6-2 easy_align.txt /*easy-align-6-2*
easy-align-6-2-1 easy_align.txt /*easy-align-6-2-1*
easy-align-6-3 easy_align.txt /*easy-align-6-3*
easy-align-6-4 easy_align.txt /*easy-align-6-4*
easy-align-6-5 easy_align.txt /*easy-align-6-5*
easy-align-6-6 easy_align.txt /*easy-align-6-6*
easy-align-6-7 easy_align.txt /*easy-align-6-7*
easy-align-6-8 easy_align.txt /*easy-align-6-8*
easy-align-6-8-1 easy_align.txt /*easy-align-6-8-1*
easy-align-7 easy_align.txt /*easy-align-7*
easy-align-7-1 easy_align.txt /*easy-align-7-1*
easy-align-7-2 easy_align.txt /*easy-align-7-2*
easy-align-8 easy_align.txt /*easy-align-8*
easy-align-9 easy_align.txt /*easy-align-9*
easy-align-adjusting-indentation easy_align.txt /*easy-align-adjusting-indentation*
easy-align-advanced-examples-and-use-cases easy_align.txt /*easy-align-advanced-examples-and-use-cases*
easy-align-aligning-delimiters-of-different-lengths easy_align.txt /*easy-align-aligning-delimiters-of-different-lengths*
easy-align-alignment-options easy_align.txt /*easy-align-alignment-options*
easy-align-alignment-options-in-interactive-mode easy_align.txt /*easy-align-alignment-options-in-interactive-mode*
easy-align-alignments-over-multiple-occurrences-of-delimiters easy_align.txt /*easy-align-alignments-over-multiple-occurrences-of-delimiters*
easy-align-author easy_align.txt /*easy-align-author*
easy-align-concept-of-alignment-rule easy_align.txt /*easy-align-concept-of-alignment-rule*
easy-align-demo easy_align.txt /*easy-align-demo*
easy-align-disabling-foldmethod-during-alignment easy_align.txt /*easy-align-disabling-foldmethod-during-alignment*
easy-align-examples easy_align.txt /*easy-align-examples*
easy-align-execution-models easy_align.txt /*easy-align-execution-models*
easy-align-extending-alignment-rules easy_align.txt /*easy-align-extending-alignment-rules*
easy-align-features easy_align.txt /*easy-align-features*
easy-align-filtering-lines easy_align.txt /*easy-align-filtering-lines*
easy-align-ignoring-delimiters-in-comments-or-strings easy_align.txt /*easy-align-ignoring-delimiters-in-comments-or-strings*
easy-align-ignoring-unmatched-lines easy_align.txt /*easy-align-ignoring-unmatched-lines*
easy-align-installation easy_align.txt /*easy-align-installation*
easy-align-interactive-mode easy_align.txt /*easy-align-interactive-mode*
easy-align-left-right-center-mode-switch-in-interactive-mode easy_align.txt /*easy-align-left-right-center-mode-switch-in-interactive-mode*
easy-align-license easy_align.txt /*easy-align-license*
easy-align-list-of-options easy_align.txt /*easy-align-list-of-options*
easy-align-live-interactive-mode easy_align.txt /*easy-align-live-interactive-mode*
easy-align-non-interactive-mode easy_align.txt /*easy-align-non-interactive-mode*
easy-align-other-options easy_align.txt /*easy-align-other-options*
easy-align-partial-alignment-in-blockwise-visual-mode easy_align.txt /*easy-align-partial-alignment-in-blockwise-visual-mode*
easy-align-predefined-alignment-rules easy_align.txt /*easy-align-predefined-alignment-rules*
easy-align-related-work easy_align.txt /*easy-align-related-work*
easy-align-tldr-one-minute-guide easy_align.txt /*easy-align-tldr-one-minute-guide*
easy-align-toc easy_align.txt /*easy-align-toc*
easy-align-usage easy_align.txt /*easy-align-usage*
easy-align-using-regular-expressions easy_align.txt /*easy-align-using-regular-expressions*
easyalign easy_align.txt /*easyalign*
g:easy_align_bang_interactive_modes easy_align.txt /*g:easy_align_bang_interactive_modes*
g:easy_align_bypass_fold easy_align.txt /*g:easy_align_bypass_fold*
g:easy_align_delimiter_align easy_align.txt /*g:easy_align_delimiter_align*
g:easy_align_delimiters easy_align.txt /*g:easy_align_delimiters*
g:easy_align_ignore_groups easy_align.txt /*g:easy_align_ignore_groups*
g:easy_align_ignore_unmatched easy_align.txt /*g:easy_align_ignore_unmatched*
g:easy_align_indentation easy_align.txt /*g:easy_align_indentation*
g:easy_align_interactive_modes easy_align.txt /*g:easy_align_interactive_modes*
vim-easy-align easy_align.txt /*vim-easy-align*

View File

@@ -1,142 +0,0 @@
" Copyright (c) 2014 Junegunn Choi
"
" MIT License
"
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be
" included in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
if exists("g:loaded_easy_align_plugin")
finish
endif
let g:loaded_easy_align_plugin = 1
command! -nargs=* -range -bang EasyAlign <line1>,<line2>call easy_align#align(<bang>0, 0, 'command', <q-args>)
command! -nargs=* -range -bang LiveEasyAlign <line1>,<line2>call easy_align#align(<bang>0, 1, 'command', <q-args>)
let s:last_command = 'EasyAlign'
function! s:abs(v)
return a:v >= 0 ? a:v : - a:v
endfunction
function! s:remember_visual(mode)
let s:last_visual = [a:mode, s:abs(line("'>") - line("'<")), s:abs(col("'>") - col("'<"))]
endfunction
function! s:repeat_visual()
let [mode, ldiff, cdiff] = s:last_visual
let cmd = 'normal! '.mode
if ldiff > 0
let cmd .= ldiff . 'j'
endif
let ve_save = &virtualedit
try
if mode == "\<C-V>"
if cdiff > 0
let cmd .= cdiff . 'l'
endif
set virtualedit+=block
endif
execute cmd.":\<C-r>=g:easy_align_last_command\<Enter>\<Enter>"
call s:set_repeat()
finally
if ve_save != &virtualedit
let &virtualedit = ve_save
endif
endtry
endfunction
function! s:repeat_in_visual()
if exists('g:easy_align_last_command')
call s:remember_visual(visualmode())
call s:repeat_visual()
endif
endfunction
function! s:set_repeat()
silent! call repeat#set("\<Plug>(EasyAlignRepeat)")
endfunction
function! s:generic_easy_align_op(type, vmode, live)
if !&modifiable
if a:vmode
normal! gv
endif
return
endif
let sel_save = &selection
let &selection = "inclusive"
if a:vmode
let vmode = a:type
let [l1, l2] = ["'<", "'>"]
call s:remember_visual(vmode)
else
let vmode = ''
let [l1, l2] = [line("'["), line("']")]
unlet! s:last_visual
endif
try
let range = l1.','.l2
if get(g:, 'easy_align_need_repeat', 0)
execute range . g:easy_align_last_command
else
execute range . "call easy_align#align(0, a:live, vmode, '')"
end
call s:set_repeat()
finally
let &selection = sel_save
endtry
endfunction
function! s:easy_align_op(type, ...)
call s:generic_easy_align_op(a:type, a:0, 0)
endfunction
function! s:live_easy_align_op(type, ...)
call s:generic_easy_align_op(a:type, a:0, 1)
endfunction
function! s:easy_align_repeat()
if exists('s:last_visual')
call s:repeat_visual()
else
try
let g:easy_align_need_repeat = 1
normal! .
finally
unlet! g:easy_align_need_repeat
endtry
endif
endfunction
nnoremap <silent> <Plug>(EasyAlign) :set opfunc=<SID>easy_align_op<Enter>g@
vnoremap <silent> <Plug>(EasyAlign) :<C-U>call <SID>easy_align_op(visualmode(), 1)<Enter>
nnoremap <silent> <Plug>(LiveEasyAlign) :set opfunc=<SID>live_easy_align_op<Enter>g@
vnoremap <silent> <Plug>(LiveEasyAlign) :<C-U>call <SID>live_easy_align_op(visualmode(), 1)<Enter>
" vim-repeat support
nnoremap <silent> <Plug>(EasyAlignRepeat) :call <SID>easy_align_repeat()<Enter>
vnoremap <silent> <Plug>(EasyAlignRepeat) :<C-U>call <SID>repeat_in_visual()<Enter>
" Backward-compatibility (deprecated)
nnoremap <silent> <Plug>(EasyAlignOperator) :set opfunc=<SID>easy_align_op<Enter>g@