11# table.vim
22
3- Your one-stop shop for all your table editing needs in Vim and Neovim. Supports
4- multi-line rows and features a cell editing window for editing cell content in a
5- separate buffer (Neovim users get a seamless floating window)
3+ Advanced table editing for Vim and Neovim. Easily create, edit, and format
4+ tables with support for multi-line rows, fixed-width columns, sorting, and
5+ various table styles. Edit cell content in a separate window for enhanced
6+ control. Highly configurable and extensible.
67
78## Quick Start
89
910Create tables using pipes ` | ` and dashes ` - ` . The table is aligned and redrawn
10- automatically on pipe insertion. Table style is configurable.
11+ automatically on pipe insertion. Table style is configurable, "double" is shown
12+ here:
1113
1214```
1315|Header 1| Header 2|Header 3| ║ Header 1 ║ Header 2 ║ Header 3 ║
@@ -26,7 +28,7 @@ And may be completed to:
2628```
2729
2830- Use ` :Table <action> ` to perform table actions like completion, sorting, and style conversion.
29- - Use ` :TableOption <option> ` to view and change configuration at runtime, such as enabling multiline rows or changing the table style.
31+ - Use ` :TableConfig <option> ` to view and change configuration at runtime, such as enabling multiline rows or changing the table style.
3032
3133See [ ` :help table.txt ` ] ( doc/table.txt ) for complete documentation.
3234
@@ -35,9 +37,16 @@ See [`:help table.txt`](doc/table.txt) for complete documentation.
3537- Vim 8.1 or later
3638- Neovim 0.11.5 or later
3739
40+ ## Upgrading from v0.1.x
41+
42+ - ** Multiline rows** are now auto-detected by default. Set ` multiline ` to ` true ` or ` false ` to override.
43+ - ** ` :TableOption ` ** is deprecated. Use ** ` :TableConfig ` ** instead.
44+ - If you used ` preserve_indentation ` , switch to ` multiline_format ` (see ` :help table-configuration ` ). Default behavior is unchanged.
45+
3846## Features
3947
40- - ** Multiline rows** - must be enabled in your configuration
48+ - ** Multiline rows** - auto-detected by default
49+ - ** Fixed-width columns** - hard-wrap columns with alignment tags
4150- ** Cell editing window** - edit in a floating window, hooks provided (split window in Vim)
4251- ** Sorting** - sort rows and columns by any column/row
4352- ** Table navigation** - move between cells even if the table is not yet aligned
@@ -46,26 +55,27 @@ See [`:help table.txt`](doc/table.txt) for complete documentation.
4655
4756## Demo
4857
58+ Note: This demo is from an older version, options have changed.
4959https://github.com/user-attachments/assets/352e23b0-33ba-4f9d-9fa0-e2aee5fd16cc
5060
5161## Configuration (optional)
5262
5363Configuration is ** buffer-local** . Set defaults in your vimrc, customize
54- per-filetype in after/ftplugin files, or change at runtime with ` :TableOption ` .
64+ per-filetype in after/ftplugin files, or change at runtime with ` :TableConfig ` .
5565
5666``` vim
5767" .vimrc - set defaults for all buffers (overridden by ftplugins)
5868call table#Setup({
5969 \ 'style': 'default',
60- \ 'options': {'multiline': v:true }
70+ \ 'options': {'multiline': 'auto', 'multiline_format': 'block_wrap' }
6171 \ })
6272```
6373
6474``` lua
6575-- init.lua - set defaults for all buffers (overridden by ftplugins)
6676require (' table_vim' ).setup ({
6777 style = ' default' ,
68- options = { multiline = true }
78+ options = { multiline = ' auto ' , multiline_format = ' block_wrap ' }
6979})
7080```
7181
@@ -93,7 +103,7 @@ keybindings work normally.
93103
94104### Navigation
95105
96- - ` <Tab> ` / ` <S-Tab> ` - Next/previous cell (wraps rows)
106+ - ` <Tab> ` / ` <S-Tab> ` - Next/previous cell
97107- ` <C-h> ` / ` <C-j> ` / ` <C-k> ` / ` <C-l> ` - Navigate left/down/up/right
98108
99109### Text Objects
@@ -123,7 +133,7 @@ nnoremap <leader>te <Plug>(table_cell_edit)
123133
124134## Commands
125135
126- Two top level commands are defined, ` :Table ` and ` :TableOption ` . Tab-completion
136+ Two top level commands are defined, ` :Table ` and ` :TableConfig ` . Tab-completion
127137is available for all subcommands and arguments.
128138
129139### ` :Table ` - Table Actions
@@ -138,19 +148,21 @@ is available for all subcommands and arguments.
138148:Table ToStyle {style} " Convert to specified style and update buffer style
139149```
140150
141- ### ` :TableOption ` - Runtime Configuration
151+ ### ` :TableConfig ` - Runtime Configuration
142152
143153Runtime configuration for the current buffer. Use without arguments to show
144154current configuration.
145155
146156``` vim
147- :TableOption " Show all current settings
148- :TableOption Style [name] " Get/set style
149- :TableOption Option [key] [value] " Get/set option
150- :TableOption StyleOption [key] [value] " Get/set style option
151- :TableOption RegisterStyle [name] " Register current style (session only)
157+ :TableConfig " Show all current settings
158+ :TableConfig Style [name] " Get/set style
159+ :TableConfig Option [key] [value] " Get/set option
160+ :TableConfig StyleOption [key] [value] " Get/set style option
161+ :TableConfig RegisterStyle [name] " Register current style (session only)
152162```
153163
164+ ** Note:** ` :TableOption ` is deprecated, use ` :TableConfig ` instead.
165+
154166** Note:** Style registration is only for the current session. Add the
155167registration to your vimrc/init.lua for persistence.
156168
@@ -166,6 +178,38 @@ Sort table rows by a specific column or sort columns by a specific row:
166178
167179See ` :help :Table-SortRows ` and ` :help :Table-SortCols `
168180
181+ ## Fixed-Width Columns
182+
183+ Set column widths using alignment tags. Tags use the format
184+ ` <[alignment][width]> ` where alignment is ` l ` (left), ` c ` (center), or ` r `
185+ (right), and width is a positive integer. Columns are padded to the specified
186+ width, and, if ` multiline ` is enabled and a ` multiline_format ` wrap option is
187+ set, long columns are also hard-wrapped to the specified width.
188+
189+ ``` vim
190+ | Description | Column 1 width |
191+ |--------------------|---------------------|
192+ | <l30> | <c10> |
193+ | Next col will wrap | This cell will wrap |
194+
195+
196+ | Description | Column 1 |
197+ | | width |
198+ |--------------------|-----------|
199+ | <l30> | <c10> |
200+ | Next col will wrap | This cell |
201+ | | will wrap |
202+ ```
203+
204+ Enable wrapping in configuration:
205+ ``` vim
206+ call table#Setup({
207+ \ 'options': {'multiline': 'auto', 'multiline_format': 'block_wrap'}
208+ \ })
209+ ```
210+
211+ See ` :help table-fixed-width ` for details.
212+
169213## Chunk Processing
170214
171215For performance, the align action (auto-align and ` :Table Align ` ) only processes
0 commit comments