Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " Author: Chinmay Vaishampayan
- " This vimrc is derived from Steve Francia's vimrc file.
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Environment {
- set nocompatible " |This setting prevents vim from emulating the original vi's bugs and limitations.
- "set background=dark " |dark background
- "}
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " General {
- scriptencoding utf-8
- filetype plugin on
- filetype indent on " |detect filetype and indent accordingly
- set mouse=a " |autmatic enable mouse usage
- set viewoptions=folds,options,cursor,unix,slash " |better unix / windows compatibility
- set virtualedit=onemore " |allow for cursor beyond last character
- set history=1000 " |increase history size
- set shortmess+=filmnrxoOtT " |abbrev. of messages (avoids 'hit enter')
- au BufWinLeave * silent! mkview " |make vim save view (state) (folds, cursor, etc)
- au BufWinEnter * silent! loadview " |make vim load view (state) (folds, cursor, etc)
- set bufhidden=hide " |Hide buffer when not in window (to prevent relogin with FTP edit)
- " }
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " VIM UI {
- set background=dark
- colorscheme ir_black
- syntax on " |Enable syntax highlight
- if has('win32') || has('win64') " |Set the font and font size
- set gfn=Consolas:h15
- endif
- set t_Co=256
- set vb t_vb= " |Flash screen on invalid command instead of beep
- set showmode " |Display current mode
- set tabpagemax=10 " |only show 15 tabs
- if has('cmdline_info')
- set ruler " |show the ruler
- set rulerformat=%35(%=\:b%n%y%m%r%w\ %l\(%L\),%c%V\ %P%) " |ruler format
- set showcmd " |show partial commands in status line and
- endif
- if has('statusline')
- set laststatus=2
- set statusline=%<%F " |Filename
- set statusline+=\ %m%r%h%w " |Options
- set statusline+=\ [b%n:\ %Y/%{&ff}] " |filetype
- "set statusline+=\ [A=\%03.3b/H=\%02.2B] " |ASCII / Hexadecimal value of char
- set statusline+=%=%-20.(%l/%L,\ %c%V%)\ %p%% " |Right aligned file nav info
- endif
- set backspace=indent,eol,start
- set linespace=0 " |No extra spaces between rows
- set nu " |Line numbers on
- set showmatch " |show matching brackets/parenthesis
- set incsearch " |find as you type search
- set hlsearch " |highlight search terms
- set winminheight=0 " |windows can be 0 line high
- set ignorecase " |case insensitive search
- set smartcase " |case sensitive when uc present
- set wildmenu " |show list instead of just completing
- set wildmode=list:longest,full " |comand <Tab> completion, list matches, then longest common part, then all.
- set whichwrap=b,s,h,l,<,>,[,] " |backspace and cursor keys wrap
- "set scrolloff=3 " |3 lines of offset(in top/bottom) while scrolling
- " }
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Formatting {
- set nowrap " |don't wrap long lines
- set autoindent " |indent at the same level of the previous line
- set smartindent " |Do smart autoindent
- set shiftwidth=4 " |use indents of 4 spaces
- set noexpandtab " |tabs are tabs, not spaces
- set tabstop=4 " |an indentation every four columns
- "set matchpairs+=<:> " |match, to be used with %
- "set pastetoggle=<F12> " |pastetoggle (sane indentation on pastes)
- "set comments=sl:/*,mb:*,elx:*/ " |auto format comment blocks
- " Remove trailing whitespaces and ^M chars
- autocmd FileType c,cpp,java,php,js,twig,xml,yml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
- " }
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Key Mappings {
- "---------------------------------------
- " Key Mappings not depending on plugins
- "---------------------------------------
- " Leader key
- "The default leader is '\', but many people prefer ',' as it's in a standard location
- let mapleader = ','
- " Save and delete buffers
- nnoremap <Leader>x :w<CR>:bd<CR>
- " Folding
- " Set space to toggle fold
- nnoremap <space> za
- " ,f to fold code between { }
- nnoremap ,f zfa{
- """ Code folding options
- nmap <leader>f0 :set foldlevel=0<CR>
- nmap <leader>f1 :set foldlevel=1<CR>
- nmap <leader>f2 :set foldlevel=2<CR>
- nmap <leader>f3 :set foldlevel=3<CR>
- nmap <leader>f4 :set foldlevel=4<CR>
- nmap <leader>f5 :set foldlevel=5<CR>
- nmap <leader>f6 :set foldlevel=6<CR>
- nmap <leader>f7 :set foldlevel=7<CR>
- nmap <leader>f8 :set foldlevel=8<CR>
- nmap <leader>f9 :set foldlevel=9<CR>
- " Autoindent
- "Shortcut to auto indent entire file (ctrl + I)
- nmap <C-I> 1G=G
- imap <C-I> <ESC>1G=Ga
- " Stupid shift key fixes
- cmap Wq wq
- cmap wQ wq
- cmap Q q
- cmap Tabe tabe
- " Easier movement between windows
- map <C-J> <C-W>j<C-W>_
- map <C-K> <C-W>k<C-W>_
- map <C-L> <C-W>l<C-W>_
- map <C-H> <C-W>h<C-W>_
- " Yank from the cursor to the end of the line, to be consistent with C and D.
- nnoremap Y y$
- " For when you forget to sudo.. save using w!!
- cmap w!! w !sudo tee % >/dev/null
- " Change Working Directory to that of the current file
- cmap cwd lcd %:p:h
- cmap cd. lcd %:p:h
- " visual shifting (does not exit Visual mode)
- vnoremap < <gv
- vnoremap > >gv
- " command for new tab
- nnoremap <Leader>nt :tabnew
- " command for tab navigation
- map <Leader>, :tabprevious<CR>
- map <Leader>. :tabnext<CR>
- " shortcut to quickly change the folder to apache workspace
- nnoremap <Leader>cd :cd C:\wamp\www\
- " shortcut to set filetype
- nnoremap <Leader>fth :set filetype=html<CR>
- nnoremap <Leader>ftp :set filetype=php<CR>
- nnoremap <Leader>ftj :set filetype=javascript<CR>
- " Shortcut to paste in insert mode
- inoremap <C-v> <Esc>"+p`]a
- "-----------------------------------
- " Key Mappings depending on plugins
- "-----------------------------------
- " plugin: checksyntax
- noremap <leader><F5> :CheckSyntax<cr>
- " plugin: taglist
- "toggle tagList, :TlistToggle, for taglist plugin
- map <F11> :TlistToggle<CR>
- "it requires ctags, to make the ctags in windows use <Leader>ct
- nmap <Leader>ct :!C:\ctags58\ctags.exe -R *<CR>
- " plugin: showmarks
- noremap <leader>s :ShowMarksToggle<cr>
- " plugin: php-doc
- nmap <leader>d :call PhpDocSingle()<CR>
- vmap <leader>d :call PhpDocRange()<CR>
- " plugin: BufExplorer
- noremap <leader>b :BufExplorer<cr>
- noremap <leader>bh :BufExplorerHorizontalSplit<cr>
- noremap <leader>bv :BufExplorerVerticalSplit<cr>
- " plugin: NERDTree
- map <C-e> :NERDTreeToggle<CR>:NERDTreeMirror<CR>
- map <F12> :NERDTreeToggle<CR>:NERDTreeMirror<CR>
- map <F10> :NERDTreeFind<CR>
- " plugin: writebackup
- nnoremap <Leader>bkp :WriteBackup<CR>
- " }
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Plugins (Settings)
- " Key mappings related to plugins are in keymappings section in last{
- " plugin: checksyntax
- let g:checksyntax_auto = 1
- " plugin: taglist
- "gain focus on TlistToggle
- let Tlist_GainFocus_On_ToggleOpen=1
- let Tlist_Auto_Highlight_Tag = 1
- let Tlist_Auto_Update = 1
- let Tlist_Exit_OnlyWindow = 1
- let Tlist_File_Fold_Auto_Close = 1
- let Tlist_Highlight_Tag_On_BufEnter = 1
- let Tlist_Use_SingleClick = 1
- let g:ctags_statusline=1
- " Override how taglist does javascript
- let g:tlist_javascript_settings = 'javascript;f:function;c:class;m:method;p:property;v:global'
- if has('win32') || has('win64')
- let Tlist_Ctags_Cmd='C:\ctags58\ctags.exe'
- endif
- " plugin: showmarks
- let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- " Don't leave on by default, use :ShowMarksOn to enable
- let g:showmarks_enable = 0
- " For marks a-z
- highlight ShowMarksHLl gui=bold guibg=LightBlue guifg=Blue
- " For marks A-Z
- highlight ShowMarksHLu gui=bold guibg=LightRed guifg=DarkRed
- " For all other marks
- highlight ShowMarksHLo gui=bold guibg=LightYellow guifg=DarkYellow
- " For multiple marks on the same line.
- highlight ShowMarksHLm gui=bold guibg=LightGreen guifg=DarkGreen
- " plugin: NERDTree
- let NERDTreeShowBookmarks=1
- let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr']
- let NERDTreeChDirMode=0
- let NERDTreeQuitOnOpen=1
- let NERDTreeShowHidden=1
- let NERDTreeKeepTreeInNewTab=1
- " plugin: supertab
- "let g:SuperTabDefaultCompletionType = "context"
- "let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
- " plugin: writebackup
- if has('win32') || has('win64')
- let g:WriteBackup_BackupDir = 'D:\backups\vim'
- else
- let g:WriteBackup_BackupDir = '~/backups/vim'
- endif
- " }
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Backup {
- set backup
- function InitBackupDir()
- let separator = "."
- let parent = $HOME .'/' . separator . 'vim/'
- let backup = parent . 'backup/'
- let tmp = parent . 'tmp/'
- if exists("*mkdir")
- if !isdirectory(parent)
- call mkdir(parent)
- endif
- if !isdirectory(backup)
- call mkdir(backup)
- endif
- if !isdirectory(tmp)
- call mkdir(tmp)
- endif
- endif
- let missing_dir = 0
- if isdirectory(tmp)
- execute 'set backupdir=' . escape(backup, " ") . "/,."
- else
- let missing_dir = 1
- endif
- if isdirectory(backup)
- execute 'set directory=' . escape(tmp, " ") . "/,."
- else
- let missing_dir = 1
- endif
- if missing_dir
- echo "Warning: Unable to create backup directories: "
- . backup ." and " . tmp
- echo "Try: mkdir -p " . backup
- echo "and: mkdir -p " . tmp
- set backupdir=.
- set directory=.
- endif
- endfunction
- call InitBackupDir()
- " }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement