Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " If you prefer the Omni-Completion tip window to close when a selection is
- " made, these lines close it on movement in insert mode or when leaving
- " insert mode
- "autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
- set nocompatible
- " :filetype plugin on
- autocmd InsertLeave * if pumvisible() == 0|pclose|endif
- autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
- function! NERDTreeQuit()
- redir => buffersoutput
- silent buffers
- redir END
- " 1BufNo 2Mods. 3File 4LineNo
- let pattern = '^\s*\(\d\+\)\(.....\) "\(.*\)"\s\+line \(\d\+\)$'
- let windowfound = 0
- for bline in split(buffersoutput, "\n")
- let m = matchlist(bline, pattern)
- if (len(m) > 0)
- if (m[2] =~ '..a..')
- let windowfound = 1
- endif
- endif
- endfor
- if (!windowfound)
- quitall
- endif
- endfunction
- "autocmd WinEnter * call NERDTreeQuit()
- function! Smart_TabComplete()
- let line = getline('.') " current line
- let substr = strpart(line, -1, col('.')+1) " from the start of the current
- " line to one character right
- " of the cursor
- let substr = matchstr(substr, "[^ \t]*$") " word till cursor
- if (strlen(substr)==0) " nothing to match on empty string
- return "\<tab>"
- endif
- let has_period = match(substr, '\.') != -1 " position of period, if any
- let has_slash = match(substr, '\/') != -1 " position of slash, if any
- if (!has_period && !has_slash)
- return "\<C-X>\<C-P>" " existing text matching
- elseif ( has_slash )
- return "\<C-X>\<C-F>" " file matching
- else
- return "\<C-X>\<C-O>" " plugin matching
- endif
- endfunction
- "inoremap <tab> <c-r>=Smart_TabComplete()<CR>
- :map <F5> :! clear && php5 %<CR>
- :map <F6> :! clear && ./build.sh %<CR>
- :map! <F5> <ESC> <F5>
- :map! <F6> <ESC> <F6>
- autocmd FileType php set omnifunc=phpcomplete#CompletePHP
- :set omnifunc=phpcomplete#CompletePHP
- :set ttyfast
- :set scrolloff=3
- ":set colorcolumn=85
- ":set cursorline
- ":set cursorcolumn
- :syntax on
- :color desert
- :set number
- :set ai
- :set laststatus=2
- :set undofile
- "autocmd VimEnter * NERDTree
- autocmd VimEnter * wincmd p
- nmap <silent> <F2> :NERDTreeToggle<CR>
- :nnoremap <silent> <C-n> :bnext<CR>
- :nnoremap <silent> <C-p> :bprevious<CR>
- :set hidden
- " Bclose
- " Delete buffer while keeping window layout (don't close buffer's windows).
- " Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
- if v:version < 700 || exists('loaded_bclose') || &cp
- finish
- endif
- let loaded_bclose = 1
- if !exists('bclose_multiple')
- let bclose_multiple = 1
- endif
- " Display an error message.
- function! s:Warn(msg)
- echohl ErrorMsg
- echomsg a:msg
- echohl NONE
- endfunction
- " Command ':Bclose' executes ':bd' to delete buffer in current window.
- " The window will show the alternate buffer (Ctrl-^) if it exists,
- " or the previous buffer (:bp), or a blank buffer if no previous.
- " Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
- " An optional argument can specify which buffer to close (name or number).
- function! s:Bclose(bang, buffer)
- if empty(a:buffer)
- let btarget = bufnr('%')
- elseif a:buffer =~ '^\d\+$'
- let btarget = bufnr(str2nr(a:buffer))
- else
- let btarget = bufnr(a:buffer)
- endif
- if btarget < 0
- call s:Warn('No matching buffer for '.a:buffer)
- return
- endif
- if empty(a:bang) && getbufvar(btarget, '&modified')
- call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
- return
- endif
- " Numbers of windows that view target buffer which we will delete.
- let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
- if !g:bclose_multiple && len(wnums) > 1
- call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
- return
- endif
- let wcurrent = winnr()
- for w in wnums
- execute w.'wincmd w'
- let prevbuf = bufnr('#')
- if prevbuf > 0 && buflisted(prevbuf) && prevbuf != w
- buffer #
- else
- bprevious
- endif
- if btarget == bufnr('%')
- " Numbers of listed buffers which are not the target to be deleted.
- let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
- " Listed, not target, and not displayed.
- let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
- " Take the first buffer, if any (could be more intelligent).
- let bjump = (bhidden + blisted + [-1])[0]
- if bjump > 0
- execute 'buffer '.bjump
- else
- execute 'enew'.a:bang
- endif
- endif
- endfor
- execute 'bdelete'.a:bang.' '.btarget
- execute wcurrent.'wincmd w'
- endfunction
- command! -bang -complete=buffer -nargs=? Bclose call s:Bclose('<bang>', '<args>')
- nnoremap <silent> <Leader>bd :Bclose<CR>
- set noundofile
- "source ~/.vim/php-doc.vim
- "inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i
- "nnoremap <C-P> :call PhpDocSingle()<CR>
- "vnoremap <C-P> :call PhpDocRange()<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement