-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
188 lines (141 loc) · 4.67 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
" Not vi-compatible
set nocompatible
" ----------------------------------------
" Vundle
" ----------------------------------------
source $HOME/.vim-bundles
" ----------------------------------------
" Settings
" ----------------------------------------
" Use UTF-8 as the default buffer encoding
set enc=utf-8
" Do not wrap lines
set nowrap
" Show line numbers
set number
" Allow backspacing over everything
set backspace=indent,eol,start
" Use 4 spaces for (auto)indent
set shiftwidth=4
" Use 4 spaces for <Tab> and :retab
set tabstop=4
set softtabstop=4
" Expand tabs to spaces
set expandtab
" Right margin to use when wrapping text
"set textwidth=72
" Enable incremental search
set incsearch
" Do not highlight results of a search
set nohlsearch
" Clear highlighted search
nmap <silent> <leader>/ :nohlsearch<CR>
" Ignore case when searching
set ignorecase
" Show line, column number, and relative position within a file in the status line
set ruler
" Indenting
set autoindent
" Show (partial) commands (or size of selection in Visual mode) in the status line
set showcmd
" Use menu to show command-line completion (in 'full' case)
set wildmenu
" Set command-line completion mode:
" - on first <Tab>, when more than one match, list all matches and complete
" the longest common string
" - on second <Tab>, complete the next full match and show menu
set wildmode=list:longest,full
" Ignore certain types of files on completion
set wildignore+=*.o,*.obj,*.pyc,.git,*.bak,.svn
" Change the mapleader from \ to ,
let mapleader=","
" Hide buffers instead of closing - multiple files, one window
set hidden
" Remember up to 1000 'colon' commmands and search patterns
set history=1000
" When a bracket is inserted, briefly jump to a matching one
set showmatch
" Jump to matching bracket for 2/10th of a second (works with showmatch)
set matchtime=2
" Changes up/down to move by line in editor
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
" Switch windows with Ctrl + a movement key
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Quickly open the vim config file in a new tab.
nmap <leader>v :tabedit $MYVIMRC<CR>
" Show hidden characters
set list listchars=tab:>·,trail:·,nbsp:.,eol:¬
" Rapidly toggle 'set list'
nmap <leader>l :set list!<CR>
" Remap ':' to ';' - Saves two strokes
nnoremap ; :
" Forget sudo?
cmap w!! w !sudo tee % >/dev/null
" Key for paste mode
set pastetoggle=<F2>
" Use <F6> to toggle line numbers
nmap <silent> <F6> :set number!<CR>
" Page down with <Space>
nmap <Space> <PageDown>
" Highight the active cursor line
set cursorline
" Colors
syntax enable
let g:solarized_termtrans=1
set background=dark
colorscheme solarized
" Enable filetype detection
if has("autocmd")
filetype plugin indent on
endif
" File Types
if has("autocmd")
autocmd BufRead,BufNewFile {*.sql} set ft=pgsql
autocmd BufRead,BufNewFile {*.haml} set ft=haml
autocmd BufRead,BufNewFile {*.rss,*.atom} set ft=xml
autocmd BufRead,BufNewFile {Gemfile,Rakefile,Capfile,*.rake,*.ru} set ft=ruby
autocmd BufRead,BufNewFile {*.md,*.mkd,*.markdown} set ft=markdown
autocmd BufRead,BufNewFile {COMMIT_EDITMSG} set ft=gitcommit
endif
" Indentation
if has("autocmd")
autocmd FileType sh,bash setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType php setlocal ts=4 sts=4 sw=4 expandtab
autocmd Filetype ruby setlocal tw=80 ts=2 sts=2 sw=2 expandtab
autocmd FileType html setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType javascript setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType css setlocal ts=4 sts=4 sw=4 expandtab
endif
" Markdown
if has("autocmd")
autocmd FileType markdown set wrap
autocmd FileType markdown set linebreak
endif
" Web
if has("autocmd")
autocmd FileType haml set nowrap
autocmd FileType sass set textwidth=0
endif
" Editing
if has("autocmd")
" Strip trailing white space on specific files
autocmd BufWritePre *.php,*.phtml,*.rb,*.htm,*.html,*.css,*.py,*.js :%s/\s\+$//ge
" Go back to the position the cursor was on the last time this file was edited
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif
endif
" PHP
if has("autocmd")
" Highlight interpolated variables in SQL strings & SQL-syntax highlighting
autocmd FileType php let php_sql_query=1
" Highlight HTML inside of PHP strings
autocmd FileType php let php_htmlInStrings=1
" Discourages use of short tags.
autocmd FileType php let php_noShortTags=1
endif