如果你只想将文本对齐成表格式,我使用它并且效果很好:
http://www.vim.org/scripts/script.php?script_id=294
几年前我写了一个命令行工具,它更贴近你想要的东西:
它允许您以CSV格式编辑表格:
1,my table,another field
2,my table,yet another field
Run Code Online (Sandbox Code Playgroud)
然后在vim中选择块,并使用以下方法对其进行过滤:
'<,'>!~/scripts/tab
Run Code Online (Sandbox Code Playgroud)
这样就可以了:
------------------------------------
| 1 | my table | another field |
| 2 | my table | yet another field |
------------------------------------
Run Code Online (Sandbox Code Playgroud)
如果要再次编辑表格,可以选择整个表格并重复untab
(这只是一个符号链接 - >选项卡),将表格再次转换回CSV,以便您进行编辑.
还有其他各种选择:
-------------------------------------------------------------------------
| Command/Option | Purpose |
|----------------|------------------------------------------------------|
| tab | Reads from stdin and tabulates comma seperated input |
| tab <-t> | Tabulates input and assumes first row are titles |
| tab <-h> | Prints this help |
| tab <-nb> | Tabulates without a border |
| tab <-fw X> | Wrap fields greater than X big don't break words |
| tab <-fs X> | Wrap fields greater than X big and break words |
| tab <-vp X> | Vertically pad table by X lines |
| tab <-hp X> | Horizontally pad fields by X chars |
| tab <-b X> | Tabulates with a border made from char X |
|----------------|------------------------------------------------------|
| untab | Reads from stdin and untabulates table input |
| untab <-b X> | Untabulate a table with border char X |
| untab <-nb> | Untabulate a borderless table |
-------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)