Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
122 lines (95 sloc) 2.87 KB
set nocompatible
set number
set ruler
syntax on
" Whitespace stuff
set nowrap
set tabstop=2
set shiftwidth=2
set expandtab
set list listchars=tab:\|_,trail:.
" Indenting
filetype plugin indent on
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
" Tab completion
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc
" Status bar
set laststatus=2
" NERDTree configuration
let NERDTreeIgnore=['\.rbc$', '\~$']
" CTags
map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
" make and python use real tabs
autocmd FileType make set noexpandtab
autocmd FileType python set noexpandtab
autocmd BufRead,BufNewFile {Gemfile,Rakefile,Thorfile} set ft=ruby
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Opens a tab edit command with the path of the currently edited file filled in
" Normal mode: <Leader>t
map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
function s:UpdateNERDTree()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
NERDTree
wincmd p
endif
endif
endfunction
function s:CommandCabbr(abbreviation, expansion)
execute 'cabbrev ' . a:abbreviation . ' <c-r>=getcmdpos() == 1 && getcmdtype() == ":" ? "' . a:expansion . '" : "' . a:abbreviation . '"<CR>'
endfunction
function s:FileCommand(name, ...)
if exists("a:1")
let funcname = a:1
else
let funcname = a:name
endif
execute 'command -nargs=1 -complete=file ' . a:name . ' :call ' . funcname . '(<f-args>)'
endfunction
function s:DefineCommand(name, destination)
call s:FileCommand(a:destination)
call s:CommandCabbr(a:name, a:destination)
endfunction
function ChangeDirectory(dir)
execute "cd " . a:dir
call s:UpdateNERDTree()
endfunction
function Touch(file)
execute "!touch " . a:file
call s:UpdateNERDTree()
endfunction
function Remove(file)
let current_path = expand("%")
let removed_path = fnamemodify(a:file, ":p")
echo current_path . ", " . removed_path
echo getbufvar("%", "&modified")
if (current_path == removed_path) && (getbufvar("%", "&modified"))
echo "You are trying to remove the file you are editing. Please close the buffer first."
else
execute "!rm " . a:file
endif
endfunction
function Edit(file)
execute "e " . a:file
call ChangeDirectory(system("dirname " . a:file))
endfunction
call s:DefineCommand("cd", "ChangeDirectory")
call s:DefineCommand("touch", "Touch")
call s:DefineCommand("rm", "Remove")
call s:DefineCommand("e", "Edit")
Jump to Line
Something went wrong with that request. Please try again.