-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc.vim
More file actions
176 lines (141 loc) · 4.49 KB
/
vimrc.vim
File metadata and controls
176 lines (141 loc) · 4.49 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
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
" If your user vim directory is something other than ~/.vim, such as
" $USERPROFILE/_vim on Windows, include the following:
" set runtimepath+=$USERPROFILE/_vim
"
" Include the following line in ~/.vimrc (or ~/_vimrc on Windows)
" runtime vimrc.vim
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set hlsearch
set number
set ruler
set nowrap
set smarttab
set showcmd
set scrolloff=15
set cursorline
set cursorcolumn
set noswapfile
set nobomb "Disable writing the byte order mark at the beginning of files...
" Pathogen Initialization....
" ===========================
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
" Not sure I want to default to a given directory now...
" lcd ~/Code
" Display a status line for [0-n] windows.
set laststatus=2
" Ignore certain types of files...
set wildignore=*.o,*.obj,*.git,*.class
" Hide the buffers instead of deleting.... Allows multiple unsaved
" buffers to be opened.
set hidden
set ofu=syntaxcomplete#Complete
syntax enable
set background=dark
let g:solarized_termcolors=256
let g:solarized_termtrans=1
colorscheme koehler
let mapleader = "-"
let maplocalleader = "\\"
nnoremap <leader>f :Find<space>
nnoremap <leader>n :NewScratchBuffer<CR>
vnoremap <leader>f gvy :Find<space><ctrl-r>"
" NERDTree....
nnoremap <leader>E :NERDTreeToggle<CR>
" Clipboard shortcuts
nnoremap <leader>y "+yy
vnoremap <leader>c "+y
" Insert clipboard contents
nnoremap <leader>iP "+P
nnoremap <leader>ip "+p
"Copy contents of entire buffer to clipboard.
nnoremap <leader>A ggVG"+y
nnoremap <leader>a ggVG
" GitGrep....
nnoremap <leader>G :GitGrep<space>
" Remap 'Search' key to mark all instances only. Use n and N to navigate to results.
nnoremap * :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
"CoffeScript plugin...
au BufRead *.coffee compiler coffee
" au BufWritePost *.coffee silent CoffeeMakee!
" EasyGrep Settings..........
" ===========================
let g:EasyGrepMode=2
let g:EasyGrepCommand=0
let g:EasyGrepRecursive=1
let g:EasyGrepIgnoreCase=1
" TagList Settings...........
" ===========================
let tlist_objc_settings = 'objc;i:interface;c:class;m:method;p:property'
" BufExplorer Plugin Settings
" ===========================
" Requires BufExplorer plugin to be installed.
" http://www.vim.org/scripts/script.php?script_id=42
nnoremap <leader>B :BufExplorer<return>
let g:bufExplorerShowDirectories=0 " Don't show directories.
let g:bufExplorerSortBy='name' " Sort by the buffer's name.
"Open file under cursor
map <C-i> :call OpenVariableUnderCursor(expand("<cword>"))<CR>
map <Leader>h :call FindSubClasses(expand("<cword>"))<CR>
" Find file in current directory and edit it.
function! Find(name)
let l:list=system("find . -name '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
if l:num < 1
echo "'".a:name."' not found"
return
endif
if l:num != 1
echo l:list
let l:input=input("Which ? (CR=nothing)\n")
if strlen(l:input)==0
return
endif
if strlen(substitute(l:input, "[0-9]", "", "g"))>0
echo "Not a number"
return
endif
if l:input<1 || l:input>l:num
echo "Out of range"
return
endif
let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*")
else
let l:line=l:list
endif
let l:line=substitute(l:line, "^[^\t]*\t./", "", "")
execute ":e ".l:line
endfunction
command! -nargs=1 Find :call Find("<args>")
function! SendToCommand(UserCommand) range
" Get a list of lines containing the selected range
let SelectedLines = getline(a:firstline,a:lastline)
" Convert to a single string suitable for passing to the command
let ScriptInput = join(SelectedLines, "\n") . "\n"
" Run the command
let result = system(a:UserCommand, ScriptInput)
" Echo the result (could just do "echo system(....)")
echo result
endfunction
command! -range -nargs=1 SendToCommand <line1>,<line2>call SendToCommand(<q-args>)
function! OpenVariableUnderCursor(varName)
let filename = substitute(a:varName,'\(\<\w\+\>\)', '\u\1', 'g')
:call OpenFileUnderCursor(filename)
endfunction
function! OpenFileUnderCursor(filename)
let ext = fnamemodify(expand("%:p"), ":t:e")
execute ":find " . a:filename . "." . ext
endfunction
function! FindSubClasses(filename)
execute ":Grep \\(implements\\|extends\\) " . a:filename
endfunction
function! NewScratchBuffer(title)
enew
setlocal buftype=nofile
"Allow for quick/easy closing of buffer...
map <buffer> q :bdelete<CR>
endfunction
command! NewScratchBuffer :call NewScratchBuffer("<args>")