-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
141 lines (123 loc) · 3.83 KB
/
.vimrc
File metadata and controls
141 lines (123 loc) · 3.83 KB
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
" make sure we use vim not vi settings
set nocompatible
set autoindent
set autowrite
set backspace=indent,eol,start
set expandtab
set hidden
set history=50
set ignorecase
set matchtime=2
set noerrorbells
set nohlsearch
set nomesg
set noshowmode
set noswapfile
set notitle
set report=5
set ruler
set shiftround
set shiftwidth=4
set shortmess=filnxtToOI
set showmatch
set sidescroll=1
set smartcase
set softtabstop=4
set splitbelow
set t_kb=
set tabstop=8
set tags=$TAGS
set textwidth=78
set viminfo='0,f0,\"100,:100,/100,@100,%,h,n$HOME/.vim/viminfo
set whichwrap=b,s,h,l
set wrapscan
" fix backspace to actually backspace
fixdel
" i always fuck these up
abbr $versionId$ $Id$ by $Author$, $DateTime$
abbr $id$ $Id$
" these abbreviations insert the current date into the buffer.
iabbr yd <c-r>=strftime("%b %d, %Y")<cr>
iabbr yld <c-r>=strftime("%a %b %d, %Y %H:%M:%S %Z")<cr>
" make ' do the same as `, that is return to row AND column
map ` '
" make [ and ] move the buffer up and down while keeping the cursor in the
" position.
map [ M
map ] M
" save current buffer and hop to the next one
map <c-n> :w<cr>:n<cr>
map <c-v> :new<cr>:0r !
" map window navigation keys to more convenient modifiers
map <c-h> <c-w>h
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
" emulate emacs' meta-.
nmap ³ :tag <c-r>=expand("<cword>")<cr><cr>
" make + and - increment and decrement numbers.
nmap + <c-a>
nmap - <c-x>
" turn on syntax mode
syntax on
if has("autocmd")
" on filetype event source type specific configuration file
autocmd FileType * call SourceFileTypeBasedConfiguration()
endif
function! SourceFileTypeBasedConfiguration()
" source type specific configuration file
"
" configuration file is: $HOME/.vim/ + filetype + .vim
" if the file exists and is readable then
" source the file
" done
let rcfile = $HOME . "/.vim/" . &filetype . ".vim"
if filereadable(rcfile)
execute "source " rcfile
endif
endfunction
if has("autocmd")
" on new file event insert type specific template into the buffer
autocmd BufNewFile * call LoadFileTypeBasedTemplate()
endif
function! LoadFileTypeBasedTemplate()
" load a template based on filetype
"
" template file is: $HOME/.vim/templates/filetype
" if the template file exists and is readable then
" read the file into the new buffer
" replace the file path place holder with the file path of this buffer
" replace the creation date place holder with the current date
" replace the hostname place holder with the current hostname
" delete extra newline at the end of the file
" done
" license file is: $HOME/.vim/licenses/filetype
" if the license file exists and is readable then
" read the file into the top of the new buffer
" done
let templatefile = $HOME . "/.vim/templates/" . &filetype
if filereadable(templatefile)
execute ":0r " templatefile
execute ":%s/__file_name__/" . expand("%") . "/eg"
execute ":%s/__file_name_root__/" . expand("%:r") . "/eg"
execute ":%s/__creation_date__/" . strftime("%Y-%m-%d") . "/eg"
execute ":%s/__hostname__/" . $HOSTNAME . "/eg"
execute ":%s/__user__/" . $USER . "/eg"
execute ":%s/__user_name__/" . "Yonatan Feldman" . "/eg"
execute ":%s/__user_email__/" . $USER . "\@milliped.com" . "/eg"
execute "normal " . "Gddgg"
endif
" let licensefile = $HOME . "/.vim/licenses/" . &filetype
" if filereadable(licensefile)
" execute ":0r " licensefile
" endif
endfunction
" command to sort a range of lines; default range is the entire buffer
command! -range=% Sort <line1>,<line2>!sort
" function to do html quoting
function! QuoteHtmlFunction() range
execute ":" . a:firstline . "," . a:lastline . "s/</\\\</eg"
execute ":" . a:firstline . "," . a:lastline . "s/>/\\\>/eg"
endfunction
" make QuoteHtml command to make this more natural
command! -range QuoteHtml <line1>,<line2>call QuoteHtmlFunction()