Skip to content

Instantly share code, notes, and snippets.

@meysampg
Created February 18, 2019 16:16
Show Gist options
  • Save meysampg/f1497d49a30239153efae59408936994 to your computer and use it in GitHub Desktop.
Save meysampg/f1497d49a30239153efae59408936994 to your computer and use it in GitHub Desktop.
my .vimrc
set nocompatible " Just use ViImporved!
"# Enable generic configurations
set backspace=indent,eol,start " Set backspace behavior normal as other editors
set number " Activate line numbers
set expandtab " Extends tab by default
set tabstop=4 " A tab actually is 4 spaces
set shiftwidth=4 " Number of spaces to use for autoindenting
set smarttab
set autoindent " Always auto indent based on previous
set copyindent " Copy the previous indentation on autoindenting
set smartindent
set cindent
set showmode " Always show currently mode
set tw=80 " Number of characters for line wrapping
"set spell spelllang=en_us " Enable spell checking
" Swap files out of the project root
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
filetype plugin on
"# Searches
set hlsearch " Highlight searches
set incsearch " Enable instance searches
set t_Co=256 " Enable 256-color mode for terminal
set ignorecase " Ignore case when searching
"# Visual
" syntax enable " Enable syntax highlighting
"## Draw a line for showing endline ;)
if (exists('+colorcolumn'))
set colorcolumn=80
endif
"## Show guideline for currect cursor positioned
set cursorline
"# Tab managment
nnoremap <leader>h :tabprevious<CR>
nnoremap <leader>l :tabnext<CR>
"# CtrlP configuration
"## Define shortcut for fuzzy finder
let g:ctrlp_cmd = 'CtrlPCurWD'
"## Define shortcut for fuzzy Variable and Method finder
nmap <c-R> :CtrlPBufTag<cr>
"## Define shortcut for most recently opened files
nmap <c-E> :CtrlPMRUFiles<cr>
"## Ignore folders
let g:ctrlp_custom_ignore = '.git'
let g:ctrlp_match_window = 'top,order:ttb,min:1,max:10,results:10'
"# PHP CS Fixer Plugin
let g:php_cs_fixer_level = "psr2"
"# Easy align interactive
vnoremap <silent> <Enter> :EasyAlign<cr>
"# NerdTree Explorer
"## Define shortcut for nerdtree
map <C-n> :NERDTreeToggle<CR>
"# php lint map
noremap <C-l> :Phplint<CR>
"# Define PASTE mode
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
"# Mapping
"## Make it easy to edit vimrc file
nmap <Leader>ev :tabedit $MYVIMRC<cr>
"## Remove hightlight of searches
nmap <Leader><cr> :nohlsearch<cr>
"## shortcut for fold of a code block
nmap <Leader>f zfa{<cr>
"## Refresh File
nmap <Leader>r :edit<cr>
"## Run current php file on console
nmap <Leader>pr :!php %<cr>
"## Toggle letter cases
nmap <Leader>u v~
"# Auto Commands
"## Automatic source MYVIMRC file after save
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source %
augroup END
"## Automatic put vim to normal mode after 1 minute inactive keyboard
"augroup putidlemode
" autocmd!
" autocmd CursorHoldI 1 <esc>
"augroup END
fun! CleanTrailingSpaces()
let curPos = getpos(".")
let oldQuery = getreg("/")
silent! %s/\s\+$//g
call setpos('.', curPos)
call setreg('/', oldQuery)
endfun
augroup removeSpanceOnSave
autocmd!
autocmd BufWritePre *.php :call CleanTrailingSpaces()
augroup END
"# PHP documenter script bound to Control-P
let g:pdv_template_dir = $HOME . '/.vim/plugged/pdv/templates_snip'
nnoremap <leader>pd :call pdv#DocumentWithSnip()<CR>
"# VimPlug Section
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
Plug 'kien/ctrlp.vim'
Plug 'airblade/vim-gitgutter'
Plug 'craigemery/vim-autotag'
Plug 'tobyS/pdv'
Plug 'jiangmiao/auto-pairs'
Plug 'rking/ag.vim', {'on': 'Ag'}
Plug 'wakatime/vim-wakatime'
Plug 'tpope/vim-surround'
Plug 'ervandew/supertab'
Plug 'junegunn/vim-easy-align'
call plug#end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment