LoginSignup
1
3

More than 3 years have passed since last update.

必要最低限のvimrc

Posted at

vimの設定はなるべく少なくすませたいと思っています

私のシンプルなvimrcです

.vimrc
noremap j gj
nnoremap k gk
set incsearch
set ignorecase
set smartcase
set hlsearch
nnoremap <ESC><ESC> :nohl<RETURN>
set expandtab
set shiftwidth=4
set tabstop=4
set autoindent
set visualbell


if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

解説

複数行にわたる長い文中でもj、kで上下移動

noremap j gj
nnoremap k gk

インクリメント検索

set incsearch

小文字で入力した場合大文字と区別しないが、大文字の場合は小文字と区別する

set ignorecase
set smartcase

検索結果をハイライト。ESC2回押しでハイライトを消す

set hlsearch
nnoremap <ESC><ESC> :nohl<RETURN>

タブの変わりにスペース4個を使う

set expandtab
set shiftwidth=4
set tabstop=4

自動インデント

set autoindent

ベルをオフ

set visualbell

ファイルを再度開いた際に、以前編集した場所にカーソルを移動

How do I get VIM to remember the line I was on when I reopen a file?

if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3