-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
152 lines (114 loc) · 3.61 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
" .vimrc
set encoding=utf-8
" load up pathogen and all bundles
call pathogen#infect()
call pathogen#helptags()
" this section for basic stuff
set nocompatible
syntax on
set term=xterm-256color
set t_Co=256
colorscheme Monokai
set backspace=indent,eol,start
"set number
"set background=dark
"set background=light
set ruler
set autoindent
set tabstop=4
set softtabstop=4 " delete will act like delete on tab (delete all spaces)
set expandtab
autocmd FileType make setlocal noexpandtab
autocmd BufEnter * :syntax sync fromstart
" different indent for different file types
autocmd Filetype html setlocal ts=2 sts=2 sw=2
autocmd Filetype ruby setlocal ts=2 sts=2 sw=2
autocmd Filetype javascript setlocal ts=2 sts=2 sw=2
" hack for perl t/*.t module test files
autocmd FileType tads set filetype=perl
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set shiftwidth=4
set shiftround
set encoding=utf8
set fileformats=unix,dos
set showmatch
set scrolloff=10
"allow one-line scroll from within insert mode
inoremap <C-E> <C-X><C-E>
inoremap <C-Y> <C-X><C-Y>
"==========================================================
" this section for fancier setup
" allow shift+TAB to create a real TAB (for makefiles)
inoremap <S-Tab> <C-V><Tab>
" display real TABs as >---
set listchars=tab:>-
set list
" then also colour real TAB areas blue
highlight TabChar ctermfg=lightblue
match TabChar /\t/
highlight All cterm=NONE ctermfg=2 ctermbg=black
au BufNewFile,BufRead *.tt2 set filetype=html
au BufNewFile,BufRead *.tt set filetype=html
" nicer colour for comments and line numbers
"highlight Comment ctermfg=DarkGreen
"highlight LineNr ctermfg=DarkGreen
" highlight the character on col 79
"highlight Col79 ctermbg=red
"match Col79 /\%<80v.\%>79v/
"==========================================================
" this section for hotkey toggle setup
" hotkey F2 to reformat current paragraph
map <F2> gq}
" hotkey F5 to toggle highlighting of real TABs
nnoremap \tl :set invlist list?<CR>
nmap <F5> \tl
imap <F5> <C-O>\tl
" hotkey F4 toggles highlighting search locations
nnoremap \th :set invhls hls?<CR>
nmap <F4> \th
imap <F4> <C-O>\th
" default is to have wrapping ON
set wrap
set sidescroll=5
set listchars+=precedes:<,extends:>
" by default text will not be auto-wrapped at 78 chars,
" but setup hotkey F6 to toggle this on and off.
" the VimEnter autocmd line is needed due to a Fedora bug
set textwidth=78
autocmd VimEnter * set formatoptions-=t
nnoremap \tf :if &fo =~ 't' <Bar> set fo-=t <Bar> else <Bar> set fo+=t <Bar> endif <Bar> set invwrap wrap?<CR>
nmap <F6> \tf
imap <F6> <C-O>\tf
" hotkey F7 to toggle paste mode
nnoremap \tp :set invpaste paste?<CR>
nmap <F7> \tp
imap <F7> <C-O>\tp
set pastetoggle=<F11>
" hotkey F8 to toggle line numbers
nnoremap \tn :set invnumber number?<CR>
nmap <F8> \tn
imap <F8> <C-O>\tn
" w!! if root privileges are required
cmap w!! %!sudo tee > /dev/null %
"==========================================================
" this section for memos...
":TOhtml
" For local replace
nnoremap gr gd[{V%:s/<C-R>///gc<left><left><left>
" For global replace
nnoremap gR gD:%s/<C-R>///gc<left><left><left>
" Enable ctrlp
set runtimepath^=~/.vim/bundle/ctrlp.vim
" set leader key to comma
let mapleader = ","
" ctrlp config
let g:ctrlp_map = '<leader>f'
let g:ctrlp_max_height = 30
let g:ctrlp_working_path_mode = 0
let g:ctrlp_match_window_reversed = 0
" use silver searcher for ctrlp
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" map Silver Searcher
map <leader>a :Ag!<space>
" search for word under cursor with Silver Searcher
map <leader>A :Ag! "<C-r>=expand('<cword>')<CR>"