VIM Extended Functions
1. Table mode
-
<prefix>
+tm
Toggle table mode enable/disable (:TableModeToggle) -
<prefix>
+tr
Align table (:TableModeRealign) -
<prefix>
+tt
This converts CSV (Comma-separated Values) data into a table. (:Tableize)
:Tableize/{pattern}
choose a specific delimiter.
:line1,line2Tableize
tablize lines manually.name, address, phone John, 1600 Pennsylvania Avenue, 0123456789 John, 1600 Pennsylvania Avenue, 0123456789 John, 1600 Pennsylvania Avenue, 0123456789 | name | address | phone | |------|--------------------------|------------| | John | 1600 Pennsylvania Avenue | 0123456789 | | John | 1600 Pennsylvania Avenue | 0123456789 | | John | 1600 Pennsylvania Avenue | 0123456789 |
-
Moving around
- add
i|
&a|
- delete row
<prefix>tdd
- delete column
<prefix>tdc
- insert colum
<prefix>tic
- add
-
Table Formulas
- add func at cell by
<prefix>tfa
# tmf: formula1;formula2;formula3
like# tmf: $3=$2*$1
`$2 = $1 * $1
$2 = pow($1, 5) NOTE: Remember to put space between the $1, and 5 here otherwise it will be treated like a table cell.
$2 = $1 / $1,3
$1,2 = $1,1 * $1,1
$5,1 = Sum(1:-1)
$5,1 = float2nr(Sum(1:-1))
$5,3 = Sum(1,2:5,2)
$5,3 = Sum(1,2:5,2)/$5,1
$5,3 = Average(1,2:5,2)/$5,1
| price | quanity | sum |
|:------|:--------|:-----|
| 12 | 4 | 48.0 |
| 21.2 | 2 | 42.4 |
| | | 90.4 |
- add func at cell by
tmf: $3=$1*$2
tmf: $3,3 = Sum(1,3:2,3)
2. Thinkinvim
3. Variable
$
——访问环境变量&
——访问 Vim 选项@
——访问寄存器
4. 行首行尾插入
- 行首 :
%s/^/your_word/
- 行尾 :
%s/$/your_word/
5. Sort
7 李华田 18.25 188 0.10
6 张永福 18.25 188 0.10
5 薛永成 26.68 188 0.14
4 陈兴 41.86 188 0.22
3 周广滨 93.34 188 0.50
2 张子寅 99.67 172 0.58
1 何维川 124.63 172 0.72
8 葛祥营 11.89 164 0.07
9 王天民 -16.55 156 -0.11
12 杨军 -213.45 152 -1.40
11 郭居岗 -86.73 152 -0.57
10 刘峰 -16.19 152 -0.11
:64,75 !sort -r -n -k4.1,5
origin:
1 何维川 124.63 172 0.72
2 张子寅 99.67 172 0.58
3 周广滨 93.34 188 0.50
4 陈兴 41.86 188 0.22
5 薛永成 26.68 188 0.14
6 张永福 18.25 188 0.10
7 李华田 18.25 188 0.10
8 葛祥营 11.89 164 0.07
9 王天民 -16.55 156 -0.11
10 刘峰 -16.19 152 -0.11
11 郭居岗 -86.73 152 -0.57
12 杨军 -213.45 152 -1.40
- r 是降序排序
- n 是按数字大小排序
- k,表示根据那个字段排序,4.1,表示第4列第一个字符开始 ,5表示到第5个字段为结束
- t 后面跟分隔符,缺省是空格