在文字周围创建表格 [英] Create table around text
问题描述
我有一个单词列表,每个单词都在自己的行上.这是表的第一列.我想手动创建第二列.
I have a list of words every is on its own line. This is the first column of a table. I'd like to create second column by hand.
我现在想使用一些插件,该插件将在文本周围创建一个ASCII表,因此我的格式很好(每列的起始字母应在一个垂直线"内,否则我应该可以快速用一个快捷方式移到正确的位置).
I'd like to use some plugin now, that will create an ASCII table around the text, so I have nice formatting (the starting letters in each column should be in one "vertical line" or I should be able to quickly move to the correct position with one shortcut).
有没有这样的vim插件,可以轻松编辑此类表并控制格式?
Is there such a plugin for vim that eases editing such tables and controls the formatting?
推荐答案
如果您只想将文本对齐为表格格式,则可以使用它,并且效果很好:
If you just want text alignment into table format, I use this and it works well:
http://www.vim.org/scripts/script.php? script_id = 294
几年前,我写了一个命令行工具,它可以更精确地满足您的要求:
I wrote a command line tool a few years ago which does more closely what you want:
它允许您以CSV格式编辑表格:
It allows you to edit a table in CSV format:
1,my table,another field
2,my table,yet another field
然后在vim中选择该块,并使用以下命令对其进行过滤:
Then select the block in vim, and filter it using:
'<,'>!~/scripts/tab
这将为您提供:
------------------------------------
| 1 | my table | another field |
| 2 | my table | yet another field |
------------------------------------
如果要再次编辑表,则可以选择整个表,然后按untab
(只是一个符号链接->选项卡)重复该操作,该操作会将表再次转换回CSV,以便您可以进行编辑.
If you want to edit the table again, you can select the whole table and repeat with untab
(which is just a symlink -> tab) which converts the table back to CSV again so that you can edit.
还有其他各种选择:
-------------------------------------------------------------------------
| 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 |
-------------------------------------------------------------------------
这篇关于在文字周围创建表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!