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.
 
 
 
 
 
 

135 lines
4.0 KiB

  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. " i dont use gvimrc
  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. augroup cch
  90. autocmd! cch
  91. autocmd WinLeave * set nocursorline
  92. autocmd WinEnter,BufRead * set cursorline
  93. augroup END
  94. hi clear CursorLine
  95. highlight CursorLine term=underline cterm=underline gui=underline
  96. " change status line color when in insert mode
  97. augroup InsertHook
  98. autocmd!
  99. autocmd InsertEnter * highlight StatusLine guifg=#ccdc90 guibg=#2E4340
  100. autocmd InsertLeave * highlight StatusLine guifg=#2E4340 guibg=#ccdc90
  101. augroup END
  102. " save window position and size
  103. if has('gui_running')
  104. let g:save_window_file = expand('~/.vimwinpos')
  105. augroup SaveWindow
  106. autocmd!
  107. autocmd VimLeavePre * call s:save_window()
  108. function! s:save_window()
  109. let options = [
  110. \ 'set columns=' . &columns,
  111. \ 'set lines=' . &lines,
  112. \ 'winpos ' . getwinposx() . ' ' . getwinposy(),
  113. \ ]
  114. call writefile(options, g:save_window_file)
  115. endfunction
  116. augroup END
  117. if filereadable(g:save_window_file)
  118. execute 'source' g:save_window_file
  119. endif
  120. endif