2013-06-27 60 views
0

我的問題很簡單,特別是那些熟悉Vim的Tabularize插件的人。我想要顯示從shell中另一個命令獲得的輸出。例如,考慮下面的命令產生給定輸出:通過對齊給定分隔符來表格化文本

$ mpc playlist 
Metallica - Ride the lightning - The call of Ktulu 
Metallica - Master of puppets - Master of puppets 
Metallica - Master of puppets - Orion (Instrumental) 
Nirvana - Nevermind - Smells like teen spirit 
Metallica - ...And justice for all - One 
Metallica - ...And justice for all - ...And justice for all 
Metallica - Kill'em all - Seek and destroy 
Metallica - Metallica - Wherever I may roam 
Metallica - Metallica - The god that failed 

我需要的是一個命令,我可以管這個輸出,並獲得以下

$ mpc playlist | tabularize --delimiter=" - " 
Metallica - Ride the lightning  - The call of Ktulu 
Metallica - Master of puppets  - Master of puppets 
Metallica - Master of puppets  - Orion (Instrumental) 
Nirvana - Nevermind    - Smells like teen spirit 
Metallica - ...And justice for all - One 
Metallica - ...And justice for all - ...And justice for all 
Metallica - Kill'em all   - Seek and destroy 
Metallica - Metallica    - Wherever I may roam 
Metallica - Metallica    - The god that failed 

任何想法?

回答

0

您正在查找的命令是column

嘗試mpc playlist | column -t -s '-' -o '-'

不幸的是,如果您在輸入中有'-'個字符,並且指定' - '將按空格進行欄目化,而不是整個字符串,則這將不起作用。

-1

**匹配一個或更多的任何跡象:「*」(貪,直到第二個連字符)
**通緝模式的開始:‘\ ZS’(VIM語法)
**匹配模式:' - '

  
:%Tab /.*\zs -/ 

  
相關問題