Last-modified: 2016-04-09 (土) 04:44:17
Vim/チートシート

基本操作

行番号

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
-
!
-
!
# 隠す
:set nonumber
# 出す
:set number

インデントを崩さずにペースト

Everything is expanded.Everything is shortened.
  1
  2
  3
 
 
 
:a!
<ペースト>
<ESC>

置換

Everything is expanded.Everything is shortened.
  1
  2
-
!
# 確認ありで置換(c:確認オプション)
:%s/<置換前文字列>/<置換後文字列>/gc

フォーマット

CP932で保存されたファイルを開く

Everything is expanded.Everything is shortened.
  1
 
:e ++enc=cp932

カラースキーマー

よく使うカラースキーマ

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
-
!
 
-
|
|
|
|
!
 
 
 
 
 
# vim74はvimのversion
sudo curl https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim -o /usr/share/vim/vim74/colors/molokai.vim
 
# vimは、90%以上iceiv+putty(半透明ウィンドウ)で触っている
# マルチディスプレイ時代の半透明ウィンドウはただのオシャレだったが
# 4Kディスプレイにして画面数が減ると、半透明ウインドウ下の文章を見ながら打てるので必須機能
# だが上のカラースキーマーを適用すると、半透明でなくなるので修正が必要
# ダウンロードしたカラースキーマを開く
:%s/hi Normal/"hi Normal/gc
 
# .vimrcに以下を追記
syntax on
colorscheme molokai
set t_Co=256

NeoBundle

インストール

公式サイト通りに行う。

Everything is expanded.Everything is shortened.
  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
 
 
 
-
-
|
|
|
!
 
 
-
|
|
!
 
 
-
!
 
 
-
!
-
|
|
|
!
 
 
-
!
 
 
-
!
curl https://raw.githubusercontent.com/Shougo/neobundle.vim/master/bin/install.sh > install.sh
sh ./install.sh
 
# .vimrcに以下を追記
" Note: Skip initialization for vim-tiny or vim-small.
if 0 | endif
 
if &compatible
  set nocompatible               " Be iMproved
endif
 
" Required:
set runtimepath^=~/.vim/bundle/neobundle.vim/
 
" Required:
call neobundle#begin(expand('~/.vim/bundle/'))
 
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
 
" My Bundles here:
" Refer to |:NeoBundle-examples|.
" Note: You don't set neobundle setting in .gvimrc!
 
call neobundle#end()
 
" Required:
filetype plugin indent on
 
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
 
# vimを起動し
:NeoBundleInstall

よく使うプラグイン

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
-
-
|
|
|
!
 
 
 
-
|
|
|
|
|
!
# .vimrcの " My Bundles here 以下に記述する
" C++ハイライト
NeoBundleLazy 'vim-jp/cpp-vim', {\
	'autoload': {'filetypes': ['h', 'hpp', 'cpp', 'cxx']}
}
" C++インテリセンス
NeoBundleLazy 'justmao945/vim-clang', {\
    'autoload': {'filetypes': ['h', 'hpp', 'cpp', 'cxx']}
}
" Doxygenフォーマットのコメント挿入(:Dox)
NeoBundleLazy 'justmao945/vim-clang', {\
	'autoload': {'filetypes': ['h', 'hpp', 'cpp', 'cxx']}
}
 
#vimを起動し
:NeoBundleInstall