2 " Fullscreen takes up entire screen
3 set fuoptions=maxhorz,maxvert
5 " Command-T for CommandT
6 macmenu &File.New\ Tab key=<D-T>
7 map <D-t> :CommandT<CR>
8 imap <D-t> <Esc>:CommandT<CR>
10 " Command-Return for fullscreen
11 macmenu Window.Toggle\ Full\ Screen\ Mode key=<D-CR>
13 " Command-Shift-F for Ack
16 " Command-e for ConqueTerm
17 map <D-e> :call StartTerm()<CR>
19 " Command-/ to toggle comments
20 map <D-/> <plug>NERDCommenterToggle<CR>
21 imap <D-/> <Esc><plug>NERDCommenterToggle<CR>i
24 " Command-][ to increase/decrease indentation
28 " Map Command-# to switch tabs
50 " Command-Option-ArrowKey to switch viewports
52 imap <D-M-Up> <Esc> <C-w>k
54 imap <D-M-Down> <Esc> <C-w>j
55 map <D-M-Right> <C-w>l
56 imap <D-M-Right> <Esc> <C-w>l
58 imap <D-M-Left> <C-w>h
60 " Adjust viewports to the same size
62 imap <Leader>= <Esc> <C-w>=
68 " Start without the toolbar
71 " Default gui color scheme
76 execute 'ConqueTerm ' . $SHELL . ' --login'
77 setlocal listchars=tab:\ \
81 if exists("loaded_nerd_tree")
82 autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
83 autocmd FocusGained * call s:UpdateNERDTree()
84 autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
87 " Close all open buffers on entering a window if the only
88 " buffer that's left is the NERDTree buffer
89 function s:CloseIfOnlyNerdTreeLeft()
90 if exists("t:NERDTreeBufName")
91 if bufwinnr(t:NERDTreeBufName) != -1
99 " If the parameter is a directory, cd into it
100 function s:CdIfDirectory(directory)
101 let explicitDirectory = isdirectory(a:directory)
102 let directory = explicitDirectory || empty(a:directory)
105 exe "cd " . fnameescape(a:directory)
108 " Allows reading from stdin
109 " ex: git diff | mvim -R -
110 if strlen(a:directory) == 0
125 " NERDTree utility function
126 function s:UpdateNERDTree(...)
133 if exists("t:NERDTreeBufName")
134 let nr = bufwinnr(t:NERDTreeBufName)
137 exe substitute(mapcheck("R"), "<CR>", "", "")
144 if exists(":CommandTFlush") == 2
149 " Utility functions to create file commands
150 function s:CommandCabbr(abbreviation, expansion)
151 execute 'cabbrev ' . a:abbreviation . ' <c-r>=getcmdpos() == 1 && getcmdtype() == ":" ? "' . a:expansion . '" : "' . a:abbreviation . '"<CR>'
154 function s:FileCommand(name, ...)
158 let funcname = a:name
161 execute 'command -nargs=1 -complete=file ' . a:name . ' :call ' . funcname . '(<f-args>)'
164 function s:DefineCommand(name, destination)
165 call s:FileCommand(a:destination)
166 call s:CommandCabbr(a:name, a:destination)
169 " Public NERDTree-aware versions of builtin functions
170 function ChangeDirectory(dir, ...)
171 execute "cd " . fnameescape(a:dir)
172 let stay = exists("a:1") ? a:1 : 1
182 execute "!touch " . shellescape(a:file, 1)
183 call s:UpdateNERDTree()
186 function Remove(file)
187 let current_path = expand("%")
188 let removed_path = fnamemodify(a:file, ":p")
190 if (current_path == removed_path) && (getbufvar("%", "&modified"))
191 echo "You are trying to remove the file you are editing. Please close the buffer first."
193 execute "!rm " . shellescape(a:file, 1)
196 call s:UpdateNERDTree()
200 execute "!mkdir " . shellescape(a:file, 1)
201 call s:UpdateNERDTree()
205 if exists("b:NERDTreeRoot")
209 execute "e " . fnameescape(a:file)
212 destination = File.expand_path(VIM.evaluate(%{system("dirname " . shellescape(a:file, 1))}))
213 pwd = File.expand_path(Dir.pwd)
214 home = pwd == File.expand_path("~")
216 if home || Regexp.new("^" + Regexp.escape(pwd)) !~ destination
217 VIM.command(%{call ChangeDirectory(fnamemodify(a:file, ":h"), 0)})
222 " Define the NERDTree-aware aliases
223 if exists("loaded_nerd_tree")
224 call s:DefineCommand("cd", "ChangeDirectory")
225 call s:DefineCommand("touch", "Touch")
226 call s:DefineCommand("rm", "Remove")
227 call s:DefineCommand("e", "Edit")
228 call s:DefineCommand("mkdir", "Mkdir")
231 " Include user's local vim config
232 if filereadable(expand("~/.gvimrc.local"))
233 source ~/.gvimrc.local