-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.local
92 lines (75 loc) · 2.55 KB
/
vimrc.local
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
"No bells or flashes
set vb t_vb=
"Soft wrap on by default
"set nowrap
"Fold using indentation, start with everything unfolded (up to level 100)
set foldmethod=indent
set foldlevel=100
"Always use spaces instead of tabs
set softtabstop=2 shiftwidth=2
set expandtab
" Don't show invisibles
set nolist
" Don't show line numbers
set nonumber
" Be tolerant with newline characters for different platforms.
set fileformats=unix,mac,dos
"Use html and js snippets in php files: Commenting out, it messes up ack. :S
" au BufRead *.php set ft=php.html.javascript
" au BufNewFile *.php set ft=php.html.javascript
" Enable cakephp snippets
au FileType php set ft=php.cakephp
" XML prettify
function! DoPrettyXML()
" save the filetype so we can restore it later
let l:origft = &ft
set ft=
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
1s/<?xml .*?>//e
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
0put ='<PrettyXML>'
$put ='</PrettyXML>'
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
2d
$d
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
silent %<
" back to home
1
" restore the filetype
exe "set ft=" . l:origft
endfunction
command! PrettyXML call DoPrettyXML()
" Ctrl+Shift+h Makes xml files pretty.
au FileType xml map <C-S-h> :PrettyXML<CR>
" Ctrl+Shift+h makes json files pretty
au FileType json map <C-S-h> :%!json_xs -f json -t json-pretty<CR>
" Banner command
autocmd FileType vim map <C-S-b> I"<Del> <Esc>A "<Del><Esc>yyp0lv$hhr=yykPjj
autocmd FileType javascript,php,c,cpp map <C-S-b> I// <Esc>A //<Esc>yyp0llv$hhhr=yykPjj
autocmd FileType python,ruby,sh,zsh map <C-S-b> I# <Esc>A #<Esc>yyp0lv$hhr=yykPjj
autocmd FileType css map <C-S-b> I/* <Esc>A */<Esc>yyp0llv$r=$hc$*/<Esc>yykPjj
" Generates Wordpress-friendly html from a markdown file
function! Markdown2wp()
!markdown % > /tmp/wp.html
tabedit /tmp/wp.html
%s@<pre><code>@[cc lang="c" escaped="true"]@g
%s@</code></pre>@[/cc]@eg
"silent s/\t/\	/eg
endfunction
" Put a colon at the end of the line
nmap ;; A;<Esc>
imap ;; <Esc>A;<Esc>
" Put a comma at the end of the line
nmap ,, A,<Esc>
imap ,, <Esc>A,<Esc>
" Command-T open files in new tab by default
let g:CommandTAcceptSelectionTabMap='<CR>'