https://github.com/junegunn/vim-easy-align
用vundle安裝, 添加下面到vimrc
Plugin 'junegunn/vim-easy-align' " Start interactive EasyAlign in visual mode (e.g. vipga) xmap ga <Plug>(EasyAlign) " Start interactive EasyAlign for a motion/text object (e.g. gaip) nmap ga <Plug>(EasyAlign)
我感覺就是使用有點難學
先用v選擇多行
ga進入easyalign模式
默認向左對其,比如按照空格對其 *<space>
向右對其 <enter>*<space>
居中對其 <enter><enter>*<space>
如果遇到其他字符比如 | , = 啥的,都把空格替換為對應的即可
*可以換成數字,對應后面的第幾個字符,*就是全部都指定
比如這個
| Option| Type | Default | Description | |--|--|--|--| | threads | Fixnum | 1 | number of threads in the thread pool | |queues |Fixnum | 1 | number of concurrent queues | |queue_size | Fixnum | 1000 | size of each queue | | interval | Numeric | 0 | dispatcher interval for batch processing | |batch | Boolean | false | enables batch processing mode | |batch_size | Fixnum | nil | number of maximum items to be assigned at once | |logger | Logger | nil | logger instance for debug logs |
試試vipga*|
vip是選擇多行,ga是進入easyalign模式,*|是指對|對齊
就變成了這樣
vipga*| | option | type | default | description | | -- | -- | -- | -- | | threads | fixnum | 1 | number of threads in the thread pool | | queues | fixnum | 1 | number of concurrent queues | | queue_size | fixnum | 1000 | size of each queue | | interval | numeric | 0 | dispatcher interval for batch processing | | batch | boolean | false | enables batch processing mode | | batch_size | fixnum | nil | number of maximum items to be assigned at once | | logger | logger | nil | logger instance for debug logs | vipga<enter>*| | option | type | default | description | | -- | -- | -- | -- | | threads | fixnum | 1 | number of threads in the thread pool | | queues | fixnum | 1 | number of concurrent queues | | queue_size | fixnum | 1000 | size of each queue | | interval | numeric | 0 | dispatcher interval for batch processing | | batch | boolean | false | enables batch processing mode | | batch_size | fixnum | nil | number of maximum items to be assigned at once | | logger | logger | nil | logger instance for debug logs | vipga<enter><enter>*| | option | type | default | description | | -- | -- | -- | -- | | threads | fixnum | 1 | number of threads in the thread pool | | queues | fixnum | 1 | number of concurrent queues | | queue_size | fixnum | 1000 | size of each queue | | interval | numeric | 0 | dispatcher interval for batch processing | | batch | boolean | false | enables batch processing mode | | batch_size | fixnum | nil | number of maximum items to be assigned at once | | logger | logger | nil | logger instance for debug logs |