You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vimrc 4.1 KiB

11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. " "load external file
  2. " if filereadable(expand('~/.dotfiles/vimrc'))
  3. " source ~/.dotfiles/vimrc
  4. " endif
  5. if !isdirectory(expand('~/.vim'))
  6. call mkdir(expand('~/.vim'))
  7. endif
  8. """""""""""""""""""""""""""""""""""
  9. set compatible " vi compatible
  10. " directory to put backup file
  11. if !isdirectory(expand('~/.vim/backup'))
  12. call mkdir(expand('~/.vim/backup'))
  13. endif
  14. set backup " enable backup
  15. set backupdir=$HOME/.vim/backup
  16. set swapfile " directory for swap file
  17. set directory=$HOME/.vim/backup
  18. set viminfo+=n~/.vim/viminfo " viminfo
  19. "set whichwrap=b,s,h,l,<,>,[,] " wrap when moving cursor
  20. set wildmode=longest,list,full
  21. set hidden " can switch to another buffer even when editting a file
  22. "set backspace=indent,eol,start " backspace can erase these things
  23. "set autochdir " automatically change current dir according to current file. cant use with mac
  24. set mouse=h " do not use mouse
  25. set clipboard+=unnamed " use x clipboard, seems not to work
  26. set browsedir=buffer " default dir for Explorer
  27. " encoding
  28. set encoding=utf-8
  29. set fileencodings=utf-8,shift-jis,euc-jp,latin1
  30. " display
  31. set showmode
  32. set title " display editting file on titlebar
  33. set list " display spcial letters such as newline or whitespace
  34. set listchars=tab:>-,extends:<,trail:-,eol:$ " set letters for displaying special letter
  35. set ruler " display current line and column
  36. set nonumber " do not show line number at left side
  37. "set laststatus=2 " always show status line
  38. set scrolloff=2 " scroll offset
  39. set showcmd
  40. set visualbell " dont beep
  41. syntax enable " enable syntax highlight
  42. " searching
  43. "set incsearch
  44. set wrapscan " wrap search
  45. set showmatch " highlight matching paren
  46. set ignorecase
  47. set smartcase " case sensitive only when capital letter is used
  48. set incsearch
  49. " tab and indent
  50. set tabstop=4 " tab width for displaying
  51. set softtabstop=4
  52. set shiftwidth=4 " width of indent
  53. set expandtab " expand tab to space
  54. set autoindent
  55. set smartindent
  56. set cindent
  57. filetype plugin indent on
  58. let g:netrw_liststyle = 1
  59. let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'
  60. " for gvim
  61. if has('gui_running')
  62. " hide toolbar and scroll bar
  63. set guioptions-=T
  64. set guioptions-=r
  65. set lines=45
  66. set columns=110
  67. set guifont=DejaVu\ Sans\ Mono\ 9
  68. endif
  69. if has('win32')
  70. " prefs for Windows
  71. endif
  72. """""""""""""""""""""""""""""""""""""""
  73. " マップ
  74. " imap <c-j> <esc> でC-Jをescにできる。?
  75. " nmap
  76. " vmap
  77. " map でそれぞれのモードでマップを指定
  78. " キーマッピングには大きく分けて map と noremap の 2 つの種類があります。
  79. " * map はキーシーケンスを展開したあと、さらに別のマップを適用しようとします。
  80. " * noremap は一度だけ展開します。
  81. " →マップを再帰的に展開するときはmap、決め打ちはnoremap(キーの入れ替えなど)
  82. " 割と保存
  83. inoremap <ESC> <ESC>:<C-u>w<CR>
  84. inoremap <C-c> <ESC>:<C-u>w<CR>
  85. noremap <C-c> <ESC>:<C-u>w<CR>
  86. " highlight current line
  87. " set cursorline
  88. " show cursor line only in current window
  89. " not work in term-mode of emacs
  90. " augroup cch
  91. " autocmd! cch
  92. " autocmd WinLeave * set nocursorline
  93. " autocmd WinEnter,BufRead * set cursorline
  94. " augroup END
  95. hi clear CursorLine
  96. highlight CursorLine term=underline cterm=underline gui=underline
  97. " change status line color when in insert mode
  98. augroup InsertHook
  99. autocmd!
  100. autocmd InsertEnter * highlight StatusLine guifg=#ccdc90 guibg=#2E4340
  101. autocmd InsertLeave * highlight StatusLine guifg=#2E4340 guibg=#ccdc90
  102. augroup END
  103. " save window position and size
  104. if has('gui_running')
  105. let g:save_window_file = expand('~/.vimwinpos')
  106. augroup SaveWindow
  107. autocmd!
  108. autocmd VimLeavePre * call s:save_window()
  109. function! s:save_window()
  110. let options = [
  111. \ 'set columns=' . &columns,
  112. \ 'set lines=' . &lines,
  113. \ 'winpos ' . getwinposx() . ' ' . getwinposy(),
  114. \ ]
  115. call writefile(options, g:save_window_file)
  116. endfunction
  117. augroup END
  118. if filereadable(g:save_window_file)
  119. execute 'source' g:save_window_file
  120. endif
  121. endif