1
1
# EasyAlign
2
2
3
- EasyAlign 是一款用来做字符对齐的插件,简直是强迫症患者的福音。
3
+ EasyAlign is a plugin for doing character alignment that is nothing short of
4
+ OCD.
4
5
5
- ## 项目地址
6
+ ## Project address
6
7
7
8
https://github.com/junegunn/vim-easy-align
8
9
9
- ## 安装
10
+ ## Installation
10
11
11
- > 修改 ` .vimrc ` 配置,在 ` call plug#begin() ` 后面添加如下配置
12
+ > Modify ` .vimrc ` configuration, add the following configuration after
13
+ > ` call plug#begin() `
12
14
13
15
``` vim
14
16
Plug 'junegunn/vim-easy-align'
15
17
```
16
18
17
- _ 注意:Vim 插件管理器的使用请参考[ plugin.md] ( ../plugin.md#插件管理 ) _
19
+ _ Note: For use of the Vim plugin manager, see [ plugin.md] (../plugin.md#plugin
20
+ management)_
21
+
22
+ > Run Vim and execute the command ` :PlugInstall ` , you may get the following
23
+ > prompt:
18
24
19
- > 运行 Vim 并执行命令 ` :PlugInstall ` , 可能会得到如下提示:
20
- >
21
25
```
22
26
1 Updated. Elapsed time: 6.008607 sec.
23
27
2 [===]
@@ -28,18 +32,18 @@ _注意:Vim 插件管理器的使用请参考[plugin.md](../plugin.md#插件
28
32
7 - vim-easy-align: Resolving deltas: 100% (136/136), done.
29
33
```
30
34
31
- ## 使用
35
+ ## Usage
32
36
33
- ### 配置
37
+ ### Configuration
34
38
35
- > 添加 ` .vimrc ` 配置如下:
39
+ > Add ` .vimrc ` configuration as follows:
36
40
37
41
``` vim
38
42
" EasyAlign
39
- xmap ga <Plug>(EasyAlign) " Visual 模式下快捷键
40
- nmap ga <Plug>(EasyAlign) " Normal 模式下快捷键
43
+ xmap ga <Plug>(EasyAlign) " The shortcut key in visual mode
44
+ nmap ga <Plug>(EasyAlign) " The shortcut key in normal mode
41
45
42
- " 配置一些自定义符号
46
+ " Configure some custom symbols
43
47
let g:easy_align_delimiters = {
44
48
\ '>': { 'pattern': '>>\|=>\|>' },
45
49
\ '/': {
@@ -66,99 +70,114 @@ let g:easy_align_delimiters = {
66
70
\ }
67
71
```
68
72
69
- ### 实验
73
+ ### Experiment
70
74
71
- > 在下面的代码中尝试如下操作:
75
+ > Try the following operations in the code below:
72
76
73
77
``` javascript
74
- let a= 1 ; // one
75
- let bcd= test= 2 ; // two
76
- let longword = others = ' some content' ; // string
78
+ let a = 1 ; // one
79
+ let bcd = ( test = 2 ) ; // two
80
+ let longword = (others = " some content" ); // string
77
81
```
78
82
79
- > 首先定位光标到上面代码中的任意一句,按 ` gaip<Space> ` ,应该会得到
80
- > 如下结果
83
+ > First locate the cursor to any sentence in the above code, press
84
+ > ` gaip<Space> ` , you should get the following results
81
85
82
86
``` javascript
83
- let a= 1 ; // one
84
- let bcd= test= 2 ; // two
85
- let longword= others= ' some content' ; // string
87
+ let a = 1 ; // one
88
+ let bcd = ( test = 2 ) ; // two
89
+ let longword = ( others = " some content" ); // string
86
90
```
87
91
88
- > 保持光标不动,按 ` gaip= ` ,应该会得到如下结果
92
+ > Keep the cursor still, press ` gaip= ` , you should get the following results
89
93
90
94
``` javascript
91
- let a = 1 ;// one
92
- let bcd = test= 2 ; // two
93
- let longword = others= ' some content' ; // string
95
+ let a = 1 ; // one
96
+ let bcd = ( test = 2 ) ; // two
97
+ let longword = ( others = " some content" ); // string
94
98
```
95
99
96
- > 保持光标不动,按 ` u ` ,再按 ` gaip*= ` ,应该会得到如下结果
100
+ > Keep the cursor still, press ` u ` , then press ` gaip*= ` , you should get the
101
+ > following results
97
102
98
103
``` javascript
99
- let a = 1 ;// one
100
- let bcd = test = 2 ; // two
101
- let longword = others = ' some content' ; // string
104
+ let a = 1 ; // one
105
+ let bcd = ( test = 2 ) ; // two
106
+ let longword = ( others = " some content" ); // string
102
107
```
103
108
104
- 下面解释一下按键的意思:
105
-
106
- - ` gaip `
107
- - ` ga ` 是开启 EasyAlign 的快捷键,我们在 ` .vimrc ` 配置文件中定义的
108
- - ` ip ` 是定义操作区域,可以用任意选择操作命令完成,` ip ` 是选择当前段落,如果光
109
- 标在代码第一行,则可以用 ` 2j ` 代替 ` ip `
110
- - 此时命令区域会出现 ` :EasyAlign (_) ` 字样,表示等待匹配输入
111
- - 按下 ` <Space> ` 是要将第一个空格前后对齐
109
+ The meaning of the keys is explained below:
110
+
111
+ - ` gaip `
112
+ - ` ga ` is the shortcut to enable EasyAlign, which we defined in the ` .vimrc `
113
+ configuration file.
114
+ - ` ip ` defines the action area, which can be done with any select action
115
+ command, ` ip ` selects the current paragraph, and if the cursor is on the
116
+ first line of code, ` 2j ` can be used instead of ` .vimrc ` . If the cursor is
117
+ on the first line of code, you can use ` 2j ` instead of ` ip ` .
118
+ - At this point, the word ` :EasyAlign (_) ` will appear in the command area,
119
+ indicating that it is waiting for matching input.
120
+ - Press ` <Space> ` to align the first space.
112
121
- ` gaip= `
113
- - 意义同上, ` = ` 即将 ` <等号> ` 前后对齐
122
+ - Same as above, ` = ` is to align the ` <equals sign> ` .
114
123
- ` gaip*= `
115
- - 为了看到更明显的效果,先用 ` u ` 撤销了前面的操作
116
- - ` = ` 前面的 ` * ` 是一个描述符,可以是数字,代表第几个等号,也可以是负数,代表
117
- 倒数第几个,也可以是星号,代表所有。
124
+ - To see the effect, undo the previous operation with ` u ` .
125
+ - The ` = ` preceded by ` * ` is a descriptor that can be a number, representing
126
+ the first equals sign, or a negative number, representing the the
127
+ penultimate number, or an asterisk for all.
118
128
119
- > 如果确定修改好了上面提到的配置,你还可以尝试 ` gaip/ ` 来对齐注释部分,执行后看
120
- > 上去会像下面这样
129
+ > If you're sure you've changed the configuration as mentioned above, you can
130
+ > also try ` gaip/ ` to align the comment section, and when executed, look at It
131
+ > will look like this
121
132
122
133
``` javascript
123
- let a = 1 ; // one
124
- let bcd = test = 2 ; // two
125
- let longword = others = ' some content' ; // string
134
+ let a = 1 ; // one
135
+ let bcd = ( test = 2 ); // two
136
+ let longword = ( others = " some content" ) ; // string
126
137
```
127
138
128
- ### 匹配符说明
139
+ ### Explanation of Match Characters
129
140
130
- 上面提到的 ` <Space> ` ` = ` 都是 EasyAlign 中定义好的特殊符号,用来表示某一类特征符
131
- ,具体可以参考下表:
141
+ The above mentioned ` <Space> ` ` = ` are special symbols defined in EasyAlign to
142
+ indicate a certain type of character. These symbols are defined in EasyAlign to
143
+ represent a certain type of character:
132
144
133
- | 按键 | 使用场景说明 |
145
+ | Keystrokes | Scenario Description |
134
146
| --- | --- |
135
- | ` <Space> ` | 匹配空白符 |
136
- | ` = ` | 包含等号的操作符( ` = ` , ` == ` , ` != ` , ` += ` , ...) |
137
- | ` : ` | 应用于 JSON 或 YAML 格式 |
138
- | ` . ` | 应用于多行点语法调用 |
139
- | ` , ` | 应用于多行参数列表 |
140
- | ` & ` | 对 [ LaTeX table] ( https://en.wikibooks.org/wiki/LaTeX/Tables ) 进行格式化,匹配 ` & ` 和 ` \\ ` |
141
- | ` # ` | 应用于对 Ruby/Python 的注释的对齐 |
142
- | ` <Bar> ` | Markdown 表格 |
147
+ | ` <Space> ` | Match whitespace |
148
+ | ` = ` | Operators containing the equals sign ( ` = ` , ` == ` , ` ! = ` , ` += ` , ...) |
149
+ | ` : ` | Applies to JSON or YAML formats |
150
+ | ` . ` | Apply to multi-line dot syntax calls |
151
+ | ` , ` | Apply to multi-line parameter lists |
152
+ | ` & ` | Format [ LaTeX table] ( https://en.wikibooks.org/wiki/LaTeX/Tables ) to match ` & ` and ` \ \\` |
153
+ | ` # ` | Apply alignment to Ruby/Python comments |
154
+ | ` <Bar> ` | Markdown tables |
143
155
144
- _ 注意:上表中提到的 ` <Bar> ` 键即 ` | ` 键 _
156
+ _ Note: The ` <Bar> ` key mentioned in the table above is the ` | ` key _ .
145
157
146
- > 尝试在上表中按 ` gaip*| ` 对 markdown 表格进行对齐
158
+ > Try to align a markdown table by ` gaip*| ` in the above table.
147
159
148
160
## Tips
149
161
150
- ### 对齐方式
162
+ ### Alignment method
151
163
152
- 在等待输入匹配符,命令区出现 ` :EasyAlign (_) ` 字样时,可以按 ` <Enter> ` 键选择对
153
- 齐方向,按一次切换为右对齐,显示 ` :EasyAlign[R] (_) ` ,再按一次切换为居中对齐,显
154
- 示为 ` :EasyAlign[C] (_) ` ,再按切换回默认的左对齐,显示也恢复原样。
164
+ When you are waiting for a match to be entered and ` :EasyAlign (_) ` appears in
165
+ the command area, you can press the ` <Enter> ` key to select the alignment
166
+ direction. Press once to switch to right alignment and display
167
+ ` :EasyAlign[R] (_) ` , press again to switch to center alignment and display
168
+ ` :EasyAlign[R] (_) ` , and press ` <Enter> ` to switch to center alignment and
169
+ display ` :EasyAlign[R] (_) ` . toggle to center alignment and display
170
+ ` :EasyAlign[C] (_) ` , then press again to switch back to the default left
171
+ alignment, and the display returns to its original state.
155
172
156
- > 在上面的 markdown 表格中尝试一下 ` gaip<Enter><Enter>*| `
173
+ > Try ` gaip<Enter><Enter>*| ` in the markdown table above.
157
174
158
- ### 正则匹配
175
+ ### Regular Matching
159
176
160
- 在等待输入匹配符时,按快捷键 ` <Ctrl-x> ` 进入匹配模式,此时输入你需要的匹配特征正
161
- 则即可匹配特殊组合。参考下面的文字:
177
+ While waiting for a match to be typed, press the shortcut key ` <Ctrl-x> ` to
178
+ enter match mode, and then type in the matching feature you want. The special
179
+ combination can be matched by typing in the matching feature you need. See the
180
+ following text:
162
181
163
182
```
164
183
Lorem<-ipsum
@@ -169,8 +188,9 @@ eiusmod<-= tempor<=- incididunt
169
188
ut <== labore
170
189
```
171
190
172
- > 尝试输入 ` gaip*<Ctrl-x> ` ,此时进入正则匹配模式,继续输入 ` <[-=~]*<Enter> ` 会得
173
- > 到如下所示结果。
191
+ > Try typing ` gaip*<Ctrl-x> ` , then it enters the regular matching mode, continue
192
+ > typing ` <[-=~]*<Enter> ` and you will get the following result. The result is
193
+ > shown below.
174
194
175
195
```
176
196
Lorem <- ipsum
@@ -181,6 +201,7 @@ eiusmod <-= tempor <=- incididunt
181
201
ut <== labore
182
202
```
183
203
184
- ### 更多参考
204
+ ### More references
185
205
186
- 更多内容请参考[ 项目页] ( https://github.com/junegunn/vim-easy-align ) 的介绍
206
+ For more references, please refer to the introduction of
207
+ [ project page] ( https://github.com/junegunn/vim-easy-align )
0 commit comments