sorahh's vimrc

raw delete

Vim muscle: 173 - Beginner

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
set nocompatible

"Absorb vimrc/.vim different OSs
if has('win32') || has ('win64')
    set shellslash
    let $VIMFILES = $VIM."/vimfiles"
else
    let $VIMFILES = $HOME."/.vim"
endif

"Add some directory to PATH if macvim
if has('gui_macvim') && !exists('s:macvim_complete_addpath')
    let s:macvim_complete_addpath = 1
    let $PATH = $HOME.'/local/bin:'.$PATH
endif

"delete all autocmds 
autocmd!

"view setting
set number

"encoding settings
set enc=utf-8
set fencs=iso-2022-jp,euc-jp,cp932
set ambiwidth=double
set fileformats=unix,dos,mac 

if !has('gui_running') && (&term == 'win32' || &term == 'win64')
    set termencoding=cp932
endif


"search settings
set ignorecase
set smartcase
set wrapscan
set incsearch
set hlsearch
hi Search term=reverse ctermbg=LightBlue ctermfg=NONE

"indent settings
set autoindent
set cindent
set tabstop=4
set shiftwidth=4
set expandtab

"show other file don't save.
set hidden

set noruler
set nolist
set showmatch
set wrap
set title

"command-line settings
set showcmd
set cmdheight=2
set laststatus=2
set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}

"command Tab complement settings
set wildmenu

set backspace=2
set scrolloff=5
set formatoptions& formatoptions+=mM
let format_join_spaces = 4
let format_allow_over_tw = 1
set nobackup
set history=1000
set mouse=a
set autochdir

"Japanese input etc settings
set imdisable
set iminsert=1
set imsearch=1

"load filetype plugins
filetype plugin on
filetype plugin indent on

"turn on the syntax-highlight
syntax on


"Rails etc autocmd
augroup Rails_etc
  autocmd!
  autocmd BufNewFile,BufRead app/*/*.rhtml set ft=mason fenc=utf-8
  autocmd BufNewFile,BufRead app/**/*.rb set ft=ruby fenc=utf-8
  autocmd BufNewFile,BufRead app/**/*.yml set ft=ruby fenc=utf-8
  autocmd FileType c hi Comment ctermfg=darkcyan
  autocmd FileType cpp hi Comment ctermfg=darkcyan
augroup END

" search
nmap n nzz
nmap N Nzz
nmap * *zz
nmap # #zz
nmap g* g*zz
nmap g# g#zz


"use vim on GNU screen settings
if &term !~ "xterm-color"
   autocmd BufEnter * if bufname("") !~ "^?[[:alnum:]?]*://" | silent! exe '!echo -n "^[k[`basename %`]^[??"' | endif
   autocmd VimLeave * silent! exe '!echo -n "^[k`dirs`^[??"'
endif

"input </ to auto close tag on XML
augroup MyXML
  autocmd!
  autocmd Filetype xml inoremap <buffer> </ </<C-x><C-o>
  autocmd Filetype html inoremap <buffer> </ </<C-x><C-o>
augroup END

"stop scatter swap
set directory-=.

"vim fighting power counter command :Scouter
command! Scouter :echo len(filter(readfile($MYVIMRC),'v:val !~ "^\\s*$\\|^\\s*\""'))

"hatena.vim settings
set runtimepath&
set runtimepath+=$VIMFILES/hatena

"ruby tab indent settings
augroup RubyIndent
    autocmd!
    autocmd Filetype ruby setlocal tabstop=4 shiftwidth=4
augroup END

"printing settings
set printoptions=wrap:y,number:y,header:0
set printfont=Andale_Mono:h12:cUTF8

"neocomplcache settings
let g:NeoComplCache_EnableAtStartup = 1 
let g:NeoComplCache_EnableCamelCaseCompletion = 1
let g:NeoComplCache_EnableUnderbarCompletion = 1
let g:NeoComplCache_EnableInfo = 1
let g:NeoComplCache_SmartCase = 1
let g:NeoComplCache_ManualCompletionStartLength = 2
nnoremap <silent> <C-s> :NeoComplCacheToggle<Return>
"nnoremap <C-d> :NeoComplCacheEnable<Return>

"spellcheck settings
"push C-a to toggle spell check
nnoremap <silent> <C-a> :setl spell!<Return>

"fold settings
set foldenable
set foldmethod=marker
set foldcolumn=3

"key-mapping for edit vimrc
nnoremap <silent> <Space>ev  :<C-u>edit $MYVIMRC<CR>
nnoremap <silent> <Space>eg  :<C-u>edit $MYGVIMRC<CR>
nnoremap <silent> <Space>ea  :source $MYVIMRC<Return>

"vimrc auto update
augroup MyAutoCmd
    autocmd!
augroup END
autocmd MyAutoCmd BufWritePost _vimrc nested source $MYVIMRC
autocmd MyAutoCmd BufWritePost _vimrc RcbVimrc

"markdown.vim setting
let g:markdownPathToMarkdown = "/Users/sorah/local/bin/markdown.pl"

"help settings
set helplang=en
nnoremap <C-h> :<C-u>help<Space>

"replace shortcut
nnoremap // :%s/

"quickrun.vim settings
let g:quickrun_direction = 'vertical rightbelow'

"split shortcut
nnoremap <silent> <C-w><C-w>l:call <SID>Goodwidth()<Cr>
nnoremap <silent> <C-w><C-w>h:call <SID>Goodwidth()<Cr>
nnoremap <silent> <C-w><C-w>L:call <SID>Goodwidth()<Cr>
nnoremap <silent> <C-w><C-w>H:call <SID>Goodwidth()<Cr>

nnoremap sl <C-w>l
nnoremap sh <C-w>h
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap sL <C-w>L
nnoremap sH <C-w>H
nnoremap sJ <C-w>J
nnoremap sK <C-w>K

"auto adjust a split window width
"http://vim-users.jp/2009/07/hack42/
function! s:Goodwidth()
  if winwidth(0) < 84
    vertical resize 90
  endif
endfunction


"tab shortcut
nnoremap <silent> tn :tabn<Cr>
nnoremap <silent> tb :tabp<Cr>
nnoremap <silent> te :tabe<Cr>

"read other vimrc files
source $VIMFILES/other/private.vim

vimrcbox © Shota Fukumori (sora_h) - Top How to use Ranking