forked from HungYuHei/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
202 lines (175 loc) · 6.14 KB
/
vimrc
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
call pathogen#infect()
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'preservim/nerdcommenter'
Plugin 'preservim/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
syntax on " 语法高亮
filetype plugin indent on " 文件类型检测
filetype plugin on
autocmd BufEnter * :syntax sync fromstart
let mapleader=","
au FocusLost * :up " auto save files when focus is lost
" 设置缩进
set expandtab
set smarttab
set shiftwidth=2
set ts=2
set nocompatible " 关闭兼容模式
set autoindent " 打开自动缩,继承前一行的缩进方式,特别适用于多行注释
set nu " 显示行号
set showcmd " 显示命令
set noswapfile " 不使用swp文件
set nobackup " 关闭备份
set incsearch " 增量式搜索
set hlsearch " 高亮搜索
set ignorecase " 搜索时忽略大小写
set magic " 额,自己:h magic吧,一行很难解释
set showmatch " 显示匹配的括号
set nowb
set lbr " 在breakat字符处而不是最后一个字符处断行
set ai " 自动缩进
" set si " 智能缩进
set history=100 " vim记住的历史操作的数量,默认的是20
set autoread " 当文件在外部被修改时,自动重新读取
set mouse=a " 在所有模式下都允许使用鼠标,还可以是n,v,i,c等
set guioptions-=R " 隐藏右边滚动条
set formatoptions+=mM " 正确地处理中文字符的折行和拼接
set whichwrap+=<,>,h,l " 退格键和方向键可以换行
set fileencodings=utf-8 " 文件UTF-8编码
set pastetoggle=<F10> " 切换粘贴模式
set ruler
"set list
"set listchars=tab:▸\ ,eol:¬
" 映射 Mac 风格的光标控制
inoremap <C-e> <END>
inoremap <C-a> <HOME>
inoremap <C-f> <Right>
inoremap <C-b> <Left>
" ^z快速进入shell
nmap <C-Z> :shell<cr>
" 把空格键映射成:
nmap <space> :
" 在NERDTree显示对应文件位置
nmap <F7> :NERDTreeFind<CR>
" NERDTree插件开关
nmap <F8> :NERDTreeToggle<CR>
" F9启动taglist插件
nnoremap <silent> <F9> :TlistToggle<CR>
" 在文件名上按gf时,在新的tab中打开
" map gf :tabnew <cfile><cr>
" Tab和Shift-Tab缩进
nmap <tab> v>
nmap <s-tab> v<
vmap <tab> >gv
vmap <s-tab> <gv
" strip all trailing whitespace in the current file
nnoremap <leader>w :%s/\s\+$//<cr>:let @/=''<CR>
" reselect the text that was just pasted
nnoremap <leader>V V`]
" 水平分割窗口
nnoremap <leader>s <C-w>s
" 垂直分割窗口
nnoremap <leader>v <C-w>v
" Ag
nnoremap <leader>a :Ag
" highlight cursor column
nnoremap <leader>lc :set cursorcolumn!<CR>
" highlight cursor line
nnoremap <leader>ll :set cursorline!<CR>
nnoremap <leader>ms :set colorcolumn=80<CR>
nnoremap <leader>mh :set colorcolumn=0<CR>
" toggle between one window and multi-window (ZoomWin plugin)
map <leader>z <C-w>o
" ToggleWord plugin
nmap <leader>t :ToggleWord<CR>
" zen-coding
map <leader>c <C-y>
" 窗口区域切换,Ctrl+jkhl 来切换
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" copy the file relative/absoulte path to the clipboard
nmap ,cp :let @*=expand("%")<CR>
" nmap ,cp :let @*=expand("%:p")<CR>
" map shortcuts for fugittive
nnoremap <leader>ga :Gwrite<CR>
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gb :Gbrowse<CR>
nnoremap <leader>gco :Gread<CR>
nnoremap <leader>gcm :Gcommit<CR>
nnoremap <leader>gdf :Gdiff<CR>
nnoremap <leader>grsh :Git reset HEAD :%<CR>
" CoffeeScript
nnoremap <leader>cf :CoffeeCompile<CR>
" RSpec
map <Leader>rc :call RunCurrentSpecFile()<CR>
map <Leader>ra :call RunAllSpecs()<CR>
let g:rspec_runner = "os_x_iterm"
"colorscheme blackboard " 使用blackboard插件的配色
colorscheme monokai
" taglist插件配置
let Tlist_Show_One_File=1 " 不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow=1 " 如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window=1 " 在右侧窗口中显示taglist窗口
" ctrlp
set runtimepath^=~/.vim/bundle/ctrlp
let g:ctrlp_working_path_mode = 2
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,.DS_Store " MacOSX/Linux
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
let Tlist_Ctags_Cmd='/usr/local/bin/ctags' " hard code here, maybe only works on my Mac
" javascript taglist
let g:tlist_javascript_settings = 'javascript;s:string;a:array;o:object;f:function'
" javascript indentation in html
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
" let g:mustache_abbreviations = 1
" clipboard
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p
" auto complete {,(,<
" inoremap ( ()<ESC>i
" inoremap [ []<ESC>i
" inoremap { {}<ESC>i
" inoremap < <><ESC>i
" inoremap " ""<ESC>i
" inoremap ' '<ESC>i
" add jbuilder syntax highlighting
au BufNewFile,BufRead *.jbuilder set ft=ruby
".vimrc
map <c-f> :call JsBeautify()<cr>
"" or
" autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr>
" for json
" autocmd FileType json noremap <buffer> <c-j> :call JsonBeautify()<cr>
" " for jsx
" autocmd FileType jsx noremap <buffer> <c-f> :call JsxBeautify()<cr>
" " for html
" autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr>
" " for css or scss
" autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>"