-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
306 lines (236 loc) · 8.09 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
" File: _vimrc
" Version: 1
" Author: Seth Mason
" Created: 19 Nov 2003 10:20:19
" Last-modified: 05 Jan 2024 15:47:52
" All my Vim commands for the taking
" Works on cygwin but not very well on unix machines...still trying to figure
" it out
" Use Vim settings, rather then Vi settings (much better!).
set nocompatible
" Turn on the verboseness to see everything vim is doing.
"set verbose=9
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" I like 4 spaces for indenting
set shiftwidth=4
" I like 4 stops
set tabstop=4
" Spaces instead of tabs
"set expandtab
" Always set auto indenting on
set autoindent
" select when using the mouse
set selectmode=mouse
" do not keep a backup files
set nobackup
set nowritebackup
if has('gui_running')
" i like about 80 character width lines
set textwidth=78
" Set 52 lines for the display
set lines=52
" 2 for the status line.
set cmdheight=2
" add columns for the Project plugin
set columns=110
" enable use of mouse
set mouse=a
" for the TOhtml command
let html_use_css=1
endif
" keep 50 lines of command line history
set history=50
" show the cursor position all the time
set ruler
" show (partial) commands
set showcmd
" do incremental searches (annoying but handy);
set incsearch
" Show tab characters. Visual Whitespace.
set list
set listchars=tab:>.
" Set ignorecase on
set ignorecase
" smart search (override 'ic' when pattern has uppers)
set scs
" Set 'g' substitute flag on
" set gdefault
" Set status line
set statusline=[%02n]\ %f\ %(\[%M%R%H]%)%=\ %4l,%02c%2V\ %P%*
" Always display a status line at the bottom of the window
set laststatus=2
" Set vim to use 'short messages'.
" set shortmess=a
" Insert two spaces after a period with every joining of lines.
" I like this as it makes reading texts easier (for me, at least).
set joinspaces
" showmatch: Show the matching bracket for the last ')'?
set showmatch
" allow tilde (~) to act as an operator -- ~w, etc.
set notildeop
" Java specific stuff
let java_highlight_all=1
let java_highlight_debug=1
let java_ignore_javadoc=1
let java_highlight_functions=1
let java_mark_braces_in_parens_as_errors=1
" highlight strings inside C comments
let c_comment_strings=1
" Commands for :Explore
let g:explVertical=1 " open vertical split winow
let g:explSplitRight=1 " Put new window to the right of the explorer
let g:explStartRight=0 " new windows go to right of explorer window
if has("gui")
" set the gui options to:
" g: grey inactive menu items
" m: display menu bar
" r: display scrollbar on right side of window
" b: display scrollbar at bottom of window
" t: enable tearoff menus on Win32
" T: enable toolbar on Win32
set go=gmr
set guifont=Courier
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
syntax on
set hlsearch
" for cygwin
set shell=C:/cygwin/bin/bash
set shellcmdflag=--login\ -c
set shellxquote=\"
" ************************************************************************
" C O M M A N D S
"
"switch to directory of current file
command! CD cd %:p:h
" ************************************************************************
" K E Y M A P P I N G S
"
map <Leader>e :Explore<cr>
map <Leader>s :Sexplore<cr>
" pressing < or > will let you indent/unident selected lines
vnoremap < <gv
vnoremap > >gv
" Don't use Ex mode, use Q for formatting
map Q gq
" Make p in Visual mode replace the selected text with the "" register.
vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>
" Make tab in v mode work like I think it should (keep highlighting):
vmap <tab> >gv
vmap <s-tab> <gv
" map ,L mz1G/Last modified:/e<Cr>CYDATETIME<Esc>`z
map ,L :let @z=TimeStamp()<Cr>"zpa
map ,datetime :let @z=strftime("%d %b %Y %X")<Cr>"zpa
map ,date :let @z=strftime("%d %b %Y")<Cr>"zpa
" Map <c-s> to write current buffer.
map <c-s> :w<cr>
imap <c-s> <c-o><c-s>
imap <c-s> <esc><c-s>
" Buffer naviation
map <M-Left> :bprevious<CR>
map <M-Right> :bnext<CR>
" Select all.
map <c-a> ggVG
" Undo in insert mode.
imap <c-z> <c-o>u
" Load my color scheme
" colorscheme slack
" ************************************************************************
" B E G I N A U T O C O M M A N D S
"
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Normally don't automatically format 'text' as it is typed, only do this
" with comments, at 79 characters.
au BufNewFile,BufEnter *.c,*.h,*.java,*.jsp set formatoptions-=t tw=79
" add an autocommand to update an existing time stamp when writing the file
" It uses the functions above to replace the time stamp and restores cursor
" position afterwards (this is from the FAQ)
autocmd BufWritePre,FileWritePre * ks|call UpdateTimeStamp()|'s
endif " has("autocmd")
" GUI ONLY type stuff.
if has("gui")
:menu &MyVim.Current\ File.Convert\ Format.To\ Dos :set fileformat=dos<cr> :w<cr>
:menu &MyVim.Current\ File.Convert\ Format.To\ Unix :set fileformat=unix<cr> :w<cr>
:menu &MyVim.Current\ File.Remove\ Trailing\ Spaces\ and\ Tabs :%s/[ ]*$//g<cr>
:menu &MyVim.Current\ File.Remove\ Ctrl-M :%s/^M//g<cr>
:menu &MyVim.Current\ File.Remove\ All\ Tabs :retab<cr>
:menu &MyVim.Current\ File.To\ HTML :runtime! syntax/2html.vim<cr>
" these don't work for some reason
":amenu &MyVim.Insert.Date<Tab>,date <Esc><Esc>:,date<Cr>
":amenu &MyVim.Insert.Date\ &Time<Tab>,datetime <Esc><Esc>:let @z=YDATETIME<Cr>"zpa
:amenu &MyVim.Insert.Last\ &Modified<Tab>,L <Esc><Esc>:let @z=TimeStamp()<CR>"zpa
:amenu &MyVim.-SEP1- <nul>
:amenu &MyVim.&Global\ Settings.Toggle\ Display\ Unprintables<Tab>:set\ list! :set list!<CR>
:amenu &MyVim.-SEP2- <nul>
:amenu &MyVim.&Project :Project<CR>
" hide the mouse when characters are typed
set mousehide
endif
" ************************************************************************
" A B B R E V I A T I O N S
"
abbr #b /************************************************************************
abbr #e ************************************************************************/
abbr hosts C:\WINNT\system32\drivers\etc\hosts
" abbreviation to manually enter a timestamp. Just type YTS in insert mode
iab YTS <C-R>=TimeStamp()<CR>
" Date/Time stamps
" %a - Day of the week
" %b - Month
" %d - Day of the month
" %Y - Year
" %H - Hour
" %M - Minute
" %S - Seconds
" %Z - Time Zone
iab YDATETIME <c-r>=strftime(": %a %b %d, %Y %H:%M:%S %Z")<cr>
" ************************************************************************
" F U N C T I O N S
"
" first add a function that returns a time stamp in the desired format
if !exists("*TimeStamp")
fun TimeStamp()
return "Last-modified: " . strftime("%d %b %Y %X")
endfun
endif
" searches the first ten lines for the timestamp and updates using the
" TimeStamp function
if !exists("*UpdateTimeStamp")
function! UpdateTimeStamp()
" Do the updation only if the current buffer is modified
if &modified == 1
" go to the first line
exec "1"
" Search for Last modified:
let modified_line_no = search("Last-modified:")
if modified_line_no != 0 && modified_line_no < 10
" There is a match in first 10 lines
" Go to the : in modified:
exe "s/Last-modified: .*/" . TimeStamp()
endif
endif
endfunction
endif
" autocmd BufNewFile,BufRead git-rebase-todo setf gitrebase
"
" Avoid syntax highlighting on big files
" https://stackoverflow.com/a/559052
autocmd BufWinEnter * if line2byte(line("$") + 1) > 1000000 | syntax clear | endif