forked from vim-jp/reading-vimrc
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc_style_guide.yml
79 lines (62 loc) · 1.76 KB
/
vimrc_style_guide.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
- id: style_001
title:
en: augroup & autocmd
ja: augroup & autocmd の使い方
content:
en: |
You should use `autocmd` with `augroup` and make sure to reset `autocmd` to make relodable vimrc
**Bad**
```vim
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
```
**Good**
```vim
augroup MyVimrc
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
```
ja: |
autocmd は augroup と一緒に使い, 定義するときは `autocmd!` で定義されたものを一旦リセットしましょう.
**Bad**
```vim
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
```
**Good**
```vim
augroup MyVimrc
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
```
help:
- :augroup
- autocmd.txt
- id: style_002
title:
en: map & noremap
ja: map & noremap
content:
en: |
You should differenciate `map` and `noremap`. {rhs} defined with `:map` will be remapped but not with `:noremap` command.
**Bad**
```vim
imap <C-f> <Left>
```
**Good**
```vim
inoremap <C-f> <Left>
```
ja: |
`map` と `noremap` は区別して使用するべきです. `:map`で定義された {rhs} は再帰的にマップが適用され, `:noremap` ではされません。
**Bad**
```vim
imap <C-f> <Left>
```
**Good**
```vim
inoremap <C-f> <Left>
```
help:
- :map
- :noremap