Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jessepav/vim-boxdraw

Vim 9 plugin to draw boxes, tables, and lines
https://github.com/jessepav/vim-boxdraw

vim vim-plugin vim9 vim9-plugin vim9script

Last synced: 7 days ago
JSON representation

Vim 9 plugin to draw boxes, tables, and lines

Awesome Lists containing this project

README

        

# BoxDraw

Draw pretty boxes in Vim

> This README was converted by hand from the
> [vimdoc](https://github.com/jessepav/vim-boxdraw/blob/master/doc/boxdraw.txt)
> included with the plugin. Please see that file for the definitive
> documentation.

## INSTALL

This plugin is written in `vim9script` and requires Vim v9.1.0120 or higher.

* [`vim-plug`](https://github.com/junegunn/vim-plug)

`Plug 'jessepav/vim-boxdraw'`

* Manual installation:

Copy files from the `plugin`, `autoload`, and `doc` directories to your `.vim`
directory.

## OVERVIEW

BoxDraw provides a command to draw boxes using ASCII or Unicode box-drawing
characters. It can also draw horizontal, vertical, and diagonal lines, and
select existing boxes.

*(We use images in the examples below because many fonts won't display all the
box types correctly.)*

### Box Styles

![box types image](https://raw.githubusercontent.com/jessepav/vim-boxdraw/master/images/boxtypes.png)

### Diagonal Lines

![diagonal lines image](https://raw.githubusercontent.com/jessepav/vim-boxdraw/master/images/diagonals.png)

### Line Joining

When you draw a "box" that is just a vertical or horizontal line, we
attempt to join the ends intelligently by examining the surrounding
characters:

![line joining image](https://raw.githubusercontent.com/jessepav/vim-boxdraw/master/images/line-joins.png)

## USAGE

Once the plugin is loaded, it provides one command:

```
:BoxDraw [box-type or command] [force] [empty]
```

You make a selection in block-wise visual mode (setting `'virtualedit'` to
`block` is very useful in this regard), and then invoke `:BoxDraw` with the
desired arguments. Or you can use the [`boxdraw-mappings`](#mappings) below.

| Argument | Description |
| ----------- | -------------- |
| box-type / command | Either one of the named box types above (`single`, `rounded`, `double`, `ascii`, `clear`), or `IBID`, to use the same box type as last time, or a special command (`SELECTBOX`, `DIAGONAL_BACKWARD`, `DIAGONAL_FORWARD`), each of which will be described below. |
| force | Use `true` or `1` to disable intelligent box joining, and just draw the type of box indicated, overwriting any existing box characters encountered. |
| empty | Use `true` or `1` to replace the interior of the box with spaces, thus "emptying" it. |

### Selection

If the command provided to `BoxDraw` is `SELECTBOX`, we examine the character
under the cursor, and attempt to visually select the box that the character
belongs to. This works for stand-alone boxes, or the enclosing box of a
table, but not for table cells. It also works better for box-types other than
`ascii`, since they have different characters for each of the four corners.

### Diagonal Lines

If the command is `DIAGONAL_FORWARD` or `DIAGONAL_BACKWARD`, we draw a
diagonal line starting at the bottom-left (for `FORWARD`) or top-left (for
`BACKWARD`) corner of the visual selection, and proceed until the line reaches
a selection boundary, horizontal or vertical.

## MAPPINGS

If the global variable `g:boxdraw_skip_mappings` is unset or is `0`, then
these mappings will be provided when the plugin is loaded:

```
# Not-forced not-emptied boxes
vnoremap bs BoxDraw single
vnoremap bd BoxDraw double
vnoremap br BoxDraw rounded
vnoremap ba BoxDraw ascii
vnoremap bc BoxDraw clear
vnoremap bb BoxDraw

# Not-forced emptied boxes
vnoremap bes BoxDraw single false true
vnoremap bed BoxDraw double false true
vnoremap ber BoxDraw rounded false true
vnoremap bea BoxDraw ascii false true
vnoremap bec BoxDraw clear false true

# Diagonals (always 'single' style)
vnoremap b/ BoxDraw DIAGONAL_FORWARD
vnoremap b\ BoxDraw DIAGONAL_BACKWARD

# Selection
vnoremap bl BoxDraw SELECTBOX

# Forced not-emptied boxes
vnoremap BS BoxDraw single true
vnoremap BD BoxDraw double true
vnoremap BR BoxDraw rounded true
vnoremap BA BoxDraw ascii true
vnoremap BC BoxDraw clear true
vnoremap BB BoxDraw IBID true

# Forced emptied boxes
vnoremap BES BoxDraw single true true
vnoremap BED BoxDraw double true true
vnoremap BER BoxDraw rounded true true
vnoremap BEA BoxDraw ascii true true
vnoremap BEC BoxDraw clear true true

# Normal mode selection
nnoremap bl BoxDraw SELECTBOX

# One-key meta shortcuts
vnoremap BoxDraw
vnoremap BoxDraw IBID true
vnoremap BoxDraw SELECTBOX
nnoremap BoxDraw SELECTBOX
```

## AUTHOR

Jesse Pavel

[email protected]\
https://github.com/jessepav/vim-boxdraw

## LICENSE

MIT