forked from mislav/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
187 lines (154 loc) · 6.22 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
" Mislav's .vimrc
"
" Thank you evil.che.lu (http://github.com/evilchelu/dotfiles/tree/master/dotted/vimrc)
set nocompatible " the past is better left in the past
set encoding=utf-8 nobomb " BOM often causes trouble
set noautochdir
set sessionoptions=folds,sesdir,tabpages,winsize
set expandtab shiftwidth=2 tabstop=2 " Ruby and JavaScript made me do it!
set noerrorbells
set visualbell " must turn visual bell on to remove audio bell
" set t_vb= " turn bells of, must also set this in .gvimrc
"""""""""" visual
syntax on
set laststatus=2 " always show status line
set scrolloff=2 " minlines to show around cursor
set sidescrolloff=4 " minchars to show around cursor
set linebreak " when wrapping, try to break at characters in breakat
set breakat=\ ^I!@*-+;:,./? " when wrapping, break at these characters
set showbreak=> " character to show that a line is wrapped
" let loaded_matchparen = 1 " don't show matching brace when moving around, it's too slow
set gdefault " global search/replace by default
set ignorecase " ignore case when searching
set smartcase " override ignorecase when there are uppercase characters
set incsearch hlsearch " highlight search matches
nmap <silent> <C-H> :silent noh<CR>
set showmatch " when inserting a bracked briefly flash its match
set showcmd " display an incomplete command (lower right corner)
" set wildmenu " nice menu when completing commands
" set wildmode=list:longest,full
if has("gui_running")
set gfn=Inconsolata\ 12
set linespace=1
set guioptions=tmaegr " menu, tearoffs, autoselect, tabline etc.
" set guioptions=ceimMgrb " aA BAD?
colorscheme oceandeep
elseif &t_Co > 2
colorscheme slate
endif
set switchbuf=usetab
" set tabpagemax=100
" splitting a window will reduce the size of the current window and leave the other windows the same:
" set noequalalways
" set guiheadroom=0
" set hidden
set splitbelow
" set browsedir=buffer
" splits to the right (vertically) from file browser
let g:netrw_altv = 1
" Minibuffer Explorer Settings
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
set ai " Turn on autoindenting
set aw " Save file when compiling, etc.
set autoread
set nobackup " Don't create backup files
set backspace=indent,eol,start " backspace over anything
set textwidth=0
"set viminfo='20,\"50 " Read/write a .viminfo file, don't store more than 50 lines of registers
"set whichwrap=b,s,<,>,[,] " End of line cursor support
set ruler
"set comments=sl:/**,mb:\ *,exl:\ */,sr:/*,mb:*,exl:*/,://
" pasting to windows apps doesn't require prefixing "*
" set clipboard=unnamed
" FIXME: don't like! how to turn off autocopy when selecting in visual mode?? (see guioptions)
" load filetype file + plugin + indent files
filetype plugin indent on
" When starting to edit a file (watch the sequence!):
" Java, C, C++ : formatting of comments; C-indenting on
" other files : switch it off
autocmd BufRead * set formatoptions=tcql nocindent comments&
autocmd BufRead *.java,*.c,*.h,*.cc set formatoptions=tcroq cindent comments=sr:/**,mb:*,elx:*/,sr:/*,mb:*,elx:*/,://
"autocmd BufRead *.rb,*.rbx,*.gem,*.gemspec,[rR]antfile,*.rant,[rR]akefile* set formatoptions=tcoq expandtab shiftwidth=2 tabstop=2
au! BufRead,BufNewFile *.sass setfiletype sass
au! BufRead,BufNewFile *.haml setfiletype haml
au BufRead,BufNewFile COMMIT_EDITMSG setf git
" never see ^M again! (DOS text files)
autocmd BufRead * silent! %s/^M$//
" alternative = :set ff=dos (:help ff for info)
" Shift-Enter inserts 'end' for ruby scripts
" Copyright (C) 2005-2007 pmade inc. (Peter Jones [email protected])
function PMADE_RubyEndToken ()
let current_line = getline('.')
let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?\(\s*#.*\)\?$'
let stuff_without_do = '^\s*\<\(class\|if\|unless\|begin\|case\|for\|module\|while\|until\|def\)\>'
let with_do = '\<do\>\s*\(|\(,\|\s\|\w\)*|\s*\)\?\(\s*#.*\)\?$'
if getpos('.')[2] < len(current_line)
return "\<CR>"
elseif match(current_line, braces_at_end) >= 0
return "\<CR>}\<C-O>O"
elseif match(current_line, stuff_without_do) >= 0
return "\<CR>end\<C-O>O"
elseif match(current_line, with_do) >= 0
return "\<CR>end\<C-O>O"
else
return "\<CR>"
endif
endfunction
function UseRubyIndent ()
setlocal tabstop=2
setlocal softtabstop=2
setlocal shiftwidth=2
setlocal expandtab
imap <buffer> <CR> <C-R>=PMADE_RubyEndToken()<CR>
endfunction
autocmd FileType ruby,eruby call UseRubyIndent()
" the evilchelu hack!
inoremap <ESC> <space><BS><ESC>
" Format the current paragraph according to
" the current 'textwidth' with CTRL-J:
nmap <C-J> gqap
vmap <C-J> gq
imap <C-J> <C-O>gqap
" do formatting - Q otherwise starts Ex mode
" map Q gq
" Delete line with CTRL-K
map <C-K> dd
imap <C-K> <C-O>dd
" omni autocomplete in insert mode:
imap <C-SPACE> <C-X><C-O>
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
" vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
" map <C-V> "+gP
map <S-Insert> "+gP
cmap <S-Insert> <C-R>+
" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update<CR>
vnoremap <C-S> <C-C>:update<CR>
inoremap <C-S> <C-O>:update<CR>
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
" CTRL-F4 is Close window
noremap <C-F4> <C-W>c
inoremap <C-F4> <C-O><C-W>c
cnoremap <C-F4> <C-C><C-W>c
onoremap <C-F4> <C-C><C-W>c
" move a window to a new tab
" map <C-T> <C-W>T
" helpful mappings for using twitter.vim
" see http://vim.sourceforge.net/scripts/script.php?script_id=1853
let g:twitterusername='mislav'
let g:twitterpassword=''
let g:gist_clip_command = 'pbcopy'
map <unique> <Leader>tp <Esc>:let g:twitterpassword=inputsecret('password? ')<CR>
map <unique> <Leader>tw <Esc>:execute 'TwitterStatusUpdate ' . inputdialog('Enter a Twitter status message:')<CR>
map <unique> <Leader>tf <Esc>:TwitterFriendsTimeline<CR>