forked from idoru/idoru-vim-config
/
vimrc_template
125 lines (95 loc) · 2.59 KB
/
vimrc_template
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
"pathogen setup
filetype off
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
"see vim-rails plugin doc [rails.txt]
set nocompatible
syntax on
filetype plugin indent on
" SHORTCUT KEY MAPPINGS """""""""""""""""""
"ctrl+alt+f for ack current word in command mode
map :call AckGrep()<CR>
function! AckGrep()
let command = "ack ".expand("<cword>")
cexpr system(command)
cw
endfunction
"prev/next in quickfix file listing (e.g. search results)
map <M-D-Down> :cn<CR>
map <M-D-Up> :cp<CR>
"select open file, MRU sorted
map <D-e> :FufBuffer<CR>
"open file
map <D-N> :FufFile **/<CR>
"opt-cmd-arrows [next & previous open files]
map <M-D-Left> :bp<CR>
map <M-D-Right> :bn<CR>
"indent/unindent visual mode selection with tab/shift+tab
vmap <tab> >gv
vmap <s-tab> <gv
"Undo/Redo using undo tree with cmd-z/cmd-shift-z
map <D-z> :earlier 1<CR>
map <D-Z> :later 1<CR>
"file tree browser - backslash
map \ :NERDTreeToggle<CR>
"simple comment/uncomment visual selection with cmd+/
vmap <silent> <D-/> :call CommentOutLine()<CR>
function! CommentOutLine()
let ext = expand("%:e")
if ext == "rb" || ext == "sh"
let comment_prefix = "#"
elseif ext == "c" || ext == "cpp" || ext == "h" || ext == "h" || ext == "m" || ext == "mm"
let comment_prefix = "//"
endif
let line = getline('.')
let pattern = "^".comment_prefix
if line =~ pattern
call setline(".", substitute(line, pattern, "", ""))
else
call setline(".", substitute(line, "^", comment_prefix, ""))
endif
endfunction
"strip trailing whitespace on save for code files
"cocoa
autocmd BufWritePre *.m,*.h,*.c,*.mm,*.cpp,*.hpp :%s/\s\+$//e
"rails
autocmd BufWritePre *.rb,*.yml,*.js,*.css,*.less,*.sass,*.html,*.xml,*.erb,*.haml :%s/\s\+$//e
"misc
autocmd BufWritePre *.java,*.php :%s/\s\+$//e
" SETTINGS """"""""""""""""""""""""""""""""
"set t_Co=256
colorscheme vividchalk
"Minibuf tab colors - must be set after colorscheme
"Changed + Hidden buffers
hi MBEChanged guibg=darkred ctermbg=darkred guifg=red ctermfg=red
"Changed + Visible buffers
hi MBEVisibleChanged guifg=darkred ctermfg=darkred
"Show whitespace, fullstops for trailing whitespace
set list
set listchars=trail:.
"Keep backup files somewhere else
set backupdir=~/.vim-tmp,~/tmp,/var/tmp,/tmp
"No swapfiles
set noswapfile
"no toolbar
set guioptions-=T
"font
set guifont=Monaco:h16
"history size
set history=1024
"incremental search
set incsearch
"no wrapping
set wrap!
"line numbers
set number
"always show statusline
set laststatus=2
"show matching brackets
set showmatch
"tab settings
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab