Skip to content

Instantly share code, notes, and snippets.

@overdrive3000
Created May 8, 2017 14:49
Show Gist options
  • Save overdrive3000/2662c7906c586d56a649d47ccb8e0e14 to your computer and use it in GitHub Desktop.
Save overdrive3000/2662c7906c586d56a649d47ccb8e0e14 to your computer and use it in GitHub Desktop.
set nocompatible " be iMproved no compatible with old VI
set t_Co=256 " Support for 256 colors
" Enabling Plug
set nocompatible
filetype off
call plug#begin('~/.vim/plugged')
" Automatic enclose
Plug 'Raimondi/delimitMate'
Plug 'tpope/vim-surround'
Plug 'Yggdroot/indentLine'
Plug 'rafi/vim-tinyline'
Plug 'kien/ctrlp.vim'
" Color schemes
Plug 'gilgigilgil/anderson.vim'
Plug 'romainl/Apprentice'
" Git plugins
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'jreybert/vimagit'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Code to execute when the plugin is lazily loaded on demand
Plug 'chase/vim-ansible-yaml', { 'for': 'ansible' }
Plug 'ekalinin/Dockerfile.vim', { 'for': 'Dockerfile' }
Plug 'python-mode/python-mode', { 'for': 'python' }
Plug 'markcornick/vim-vagrant'
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User goyo.vim echom 'Goyo is now loaded!'
call plug#end()
filetype plugin indent on
syntax on
colorscheme apprentice
" Set soft wrap for .txt file
autocmd BufNewFile,BufRead *.txt set wrap linebreak nolist
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=1000
" Ignore some file
set wildignore=*.swp,*.bak,*.pyc,*.class
" Set to auto read when a file is changed from the outside
set autowrite
" With a map leader it's possible to do extra key combinations
" leader is press comma (,) key
" like <leader>w saves the current file
let mapleader=","
let g:mapleader=","
" Fast saving with leader + w
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e! ~/.vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=2
set softtabstop=2
set shiftwidth=2
set textwidth=80
set smarttab
set expandtab
" Set linebreak and textwidth
set lbr
set tw=500
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set so=7 " Set 7 lines to the curors - when moving vertical..
set ruler "Always show current position
set hid "Change buffer - without saving
set nohidden
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set nolazyredraw "Don't redraw while executing macros
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
" No sound on errors
set noerrorbells
set novisualbell
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable "Enable syntax hl
set shell=/bin/bash
" Specific options for Vim GTK
set guioptions-=T
set background=dark
let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
set nonu
set gfn=Liberation\ Mono\ 10
set encoding=utf8
try
lang en_US
catch
endtry
if has("gui_running")
" GUI is running or is about to start.
" Maximize gvim window.
set lines=43
set co=87
colorscheme apprentice
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowb
set noswapfile
set undodir=~/.vim/undodir
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Useful when moving accross long lines
" map j gj
" map k gk
map <silent> <leader><cr> :nohlsearch<cr>
" GRB: clear the search buffer when hitting return
nnoremap <CR> :nohlsearch<CR>/<BS>
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
" Movimientos entre tabs
" tab navigation like firefox
nnoremap <leader><Left> :tabprevious<cr>
nnoremap <leader><Right> :tabnext<cr>
nnoremap <leader><Up> :bnext<cr>
nnoremap <leader><Down> :bprevious<cr>
nnoremap <C-t> :tabnew! %<CR>
" nnoremap <C-S-tab> :tabprevious<CR>
" nnoremap <C-tab> :tabnext<CR>
" nnoremap <C-t> :tabnew<CR>
" inoremap <C-S-tab> <Esc>:tabprevious<CR>i
" inoremap <C-tab> <Esc>:tabnext<CR>i
" inoremap <C-t> <Esc>:tabnew<CR>
" nnoremap <A-F1> 1gt
" nnoremap <A-F2> 2gt
" nnoremap <A-F3> 3gt
" nnoremap <A-F4> 4gt
" nnoremap <A-F5> 5gt
" nnoremap <A-F6> 6gt
" nnoremap <A-F7> 7gt
" nnoremap <A-F8> 8gt
" nnoremap <A-F9> 9gt
" nnoremap <A-F0> 10gt
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" My CUSTOM
"
set cmdheight=1 " Explicitly set the height of the command line
set number " Display line numbers
set numberwidth=1 " using only 1 column (and 1 space) while possible
set title " show title in console title bar
set wildmenu " Menu completion in command mode on <Tab>
set pastetoggle=<F3> " Press F3 for toggle paste mode
set cursorline
" set colorcolumn=80 " Mark 80th column with a red line
" Set default environment based on current edited files
autocmd BufEnter * silent! lcd %:p:h
" have command-line completion <tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <tab>s cycle through the possibilities:
set wildmode=list:longest,full
set nowrap " no line wrapping;
set guioptions+=b " add a horizontal scrollbar to the bottom
"--- search options ------------
set incsearch " show 'best match so far' as you type
set hlsearch " hilight the items found by the search
set ignorecase " ignores case of letters on searches
set smartcase " Override the 'ignorecase' option if the search pattern contains upper case characters
" Search and error color highlights
hi Search guifg=#ffffff guibg=#0000ff gui=none ctermfg=white ctermbg=darkblue
hi IncSearch guifg=#ffffff guibg=#8888ff gui=none ctermfg=white
highlight SpellBad guifg=#ffffff guibg=#8888ff gui=none ctermfg=black ctermbg=darkred
" Use UTF-8 as the default buffer encoding
set enc=utf-8
" Always show status line, even for one window
set laststatus=2
" Scroll when cursor gets within 3 characters of top/bottom edge
set scrolloff=3
" Round indent to multiple of 'shiftwidth' for > and < commands
set shiftround
" Show (partial) commands (or size of selection in Visual mode) in the status line
set showcmd
"--- Keystrokes ----------------
" h and l wrap between lines, cursor keys wrap in insertion mode
set whichwrap=h,l,~,[,]
" Shortcut to Close quickfix window with leader+c
nnoremap <leader>c <CR>:cclose<CR>
""" Block identation
vnoremap < <gv
vnoremap > >gv
nnoremap <Tab> >>_
nnoremap <S-Tab> <<_
inoremap <S-Tab> <C-D>
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
""" Cloudformation syntax highlitghing
au BufNewFile,BufRead *.template set filetype=yaml
"--- Python Specific Configuration -----
"
" Set autocomplete form
set completeopt=menuone,longest,preview
" Enable omni completion.
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown,ctp set omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
" autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php,ctp set omnifunc=phpcomplete#CompletePHP
autocmd FileType vim set omnifunc=syntaxcomplete#Complete
" Python mode customization
let g:pymode_folding=0
let g:pymode_lint_checker="pylint"
let g:pymode_lint_ignore = "E501,C0301"
let g:pymode_rope_guess_project=0
let g:pymode_virtualenv = 1
let g:pymode_virtualenv_path = $VIRTUAL_ENV
" Rope autocomplete
let g:pymode_rope = 1
let ropevim_vim_completion=1
let ropevim_extended_complete=1
let g:pymode_rope_autoimport = 1
let g:ropevim_autoimport_modules=["os.*","traceback","django.*","xml.etree"]
let g:pymode_rope_completion = 1
" let g:pymode_rope_complete_on_dot = 1
"
" NERDTree
map <C-n> :NERDTreeToggle<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment