LoginSignup
2
6

More than 5 years have passed since last update.

.vimrcの設定

Posted at

vimの設定(.vimrc)

.vimrc
"color_schemeの設定
let g:hybrid_use_iTerm_colors = 1
hi String     ctermfg=red guifg=Orange cterm=none gui=none
syntax on

"tab幅の設定
set tabstop=2
set expandtab
set shiftwidth=2
"連続した空白に対するカーソルの動く幅
set softtabstop=2

"行番号の表示
set number
"スワップファイルを作らない
set noswapfile

"自動インデント
set smartindent
set autoindent

"[検索]大文字小文字を区別しない
set ignorecase
set smartcase
"1文字入力ごとに検索を行う
set incsearch
"検索結果のハイライト
set hlsearch
"ハイライトの切り替え
nnoremap <silent><Esc><Esc> :<C-u>set nohlsearch!<CR>

"保存時の文字コード
set fileencoding=utf-8
"読み込み時の文字コードの自動判別、左優先
set fileencodings=ucs-boms,utf-8,euc-jp,cp932
"改行コードの自動判別、左側優先
set fileformats=unix,dos,mac
"◻や◯が崩れるのを防ぐ(iTerm2の設定から一部変更の必要性))
set ambiwidth=double

"カーソルの左右移動で行末から行頭への移動
set whichwrap=b,s,h,l,<,>,[,],~
"カーソルラインのハイライト
set cursorline
" 行が折り返し表示されていた場合、行単位ではなく表示行単位でカーソルを移動する
nnoremap j gj
nnoremap k gk
nnoremap <down> gj
nnoremap <up> gk

"コマンドモードの補完
set wildmenu
"保存するコマンド履歴の数
set history=5000
"クリップボードからコピペする際のインデントのズレを防ぐ
if &term =~ "xterm"
  let &t_SI .= "\e[?2004h"
  let &t_EI .= "\e[?2004l"
  let &pastetoggle = "\e[201~"

  function XTermPasteBegin(ret)
    set paste
    return a:ret
  endfunction

  inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("")
endif


"マウス操作の有効化
if has('mouse')
  set mouse=a
  if has('mouse_sgr')
    set ttymouse=sgr
  elseif v:version > 703 || v:version is 703 && has('patch632')
    set ttymouse=sgr
  else
    set ttymouse=xterm2
  endif
endif


"NeoBundle
if has('vim_starting')
    " 初回起動時のみruntimepathにNeoBundleのパスを指定する
    set runtimepath+=~/.vim/bundle/neobundle.vim/

    " NeoBundleが未インストールであればgit cloneする・・・・・・①
    if !isdirectory(expand("~/.vim/bundle/neobundle.vim/"))
        echo "install NeoBundle..."
        :call system("git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim")
    endif
endif

call neobundle#begin(expand('~/.vim/bundle/'))

" インストールするVimプラグインを以下に記述
" NeoBundle自身を管理
NeoBundleFetch 'Shougo/neobundle.vim'
"----------------------------------------------------------
" ここに追加したいVimプラグインを記述する・・・・・・②

"カッコの自動閉じ
NeoBundle 'Townk/vim-autoclose'

" ステータスラインの表示内容強化
NeoBundle 'itchyny/lightline.vim'

"sudo vimのときにも設定が反映される(vim sudo:xxx)
NeoBundle 'sudo.vim'

"----------------------------------------------------------
" ステータスラインの設定
"----------------------------------------------------------
set laststatus=2 " ステータスラインを常に表示
set showmode " 現在のモードを表示
set showcmd " 打ったコマンドをステータスラインの下に表示
set ruler " ステータスラインの右側にカーソルの現在位置を表示する

" インデントの可視化
NeoBundle 'Yggdroot/indentLine'


" Plugin key-mappings.
inoremap <expr><C-g>     neocomplcache#undo_completion()
inoremap <expr><C-l>     neocomplcache#complete_common_string()

"----------------------------------------------------------
call neobundle#end()

" ファイルタイプ別のVimプラグイン/インデントを有効にする
filetype plugin indent on

" 未インストールのVimプラグインがある場合、インストールするかどうかを尋ねてくれるようにする設定・・・・・・③
NeoBundleCheck

いろいろ設定してみてとりあえずはこんな感じ
行末から左右のカーソルで移動できるのとかは使い勝手が良くておすすめ

※カラースキームは別のとこからダウンロードしてきたものなのでそのままだとエラー出るかも

最近はzshが気になっているので試してみたい

2
6
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
2
6