You should use autocmd
with augroup
and make sure to reset autocmd
to make relodable vimrc
Bad
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
Good
augroup MyVimrc
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
:augroup
autocmd.txt
You should differenciate map
and noremap
. {rhs} defined with :map
will be remapped but not with :noremap
command.
Bad
imap <C-f> <Left>
Good
inoremap <C-f> <Left>
:map
:noremap
autocmd は augroup と一緒に使い, 定義するときは autocmd!
で定義されたものを一旦リセットしましょう.
Bad
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
Good
augroup MyVimrc
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
:augroup
autocmd.txt
map
と noremap
は区別して使用するべきです. :map
で定義された {rhs} は再帰的にマップが適用され, :noremap
ではされません。
Bad
imap <C-f> <Left>
Good
inoremap <C-f> <Left>
:map
:noremap