Skip to content

Instantly share code, notes, and snippets.

@guimaluf
Last active November 20, 2019 21:20
Show Gist options
  • Save guimaluf/91a90a8d0f345bbe0139591e60c7610d to your computer and use it in GitHub Desktop.
Save guimaluf/91a90a8d0f345bbe0139591e60c7610d to your computer and use it in GitHub Desktop.
if $TERM == "xterm-256color"
set t_Co=256
endif
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'PotatoesMaster/i3-vim-syntax'
Plugin 'airblade/vim-gitgutter'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'godlygeek/tabular'
Plugin 'huawenyu/vim-log-syntax'
Plugin 'jiangmiao/auto-pairs'
Plugin 'mattn/emmet-vim'
Plugin 'mbbill/undotree'
Plugin 'michaeljsmith/vim-indent-object'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'pearofducks/ansible-vim'
Plugin 'python-mode/python-mode'
Plugin 'rodjek/vim-puppet'
Plugin 'sheerun/vim-polyglot'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'vim-latex/vim-latex'
Plugin 'vim-ruby/vim-ruby'
Plugin 'wellle/targets.vim'
Plugin 'zirrostig/vim-schlepp'
call vundle#end()
filetype plugin indent on
colorscheme murphy
"colorscheme moonfly
syntax on
" spellchecking
set spelllang=pt,en
" enconding
set encoding=utf8
" highlight search pattern
set hlsearch
" do incremental search
set incsearch
" ignore case in the search pattern
set ignorecase
" search with regexp
set magic
" mouse
set mouse=a
" avoid paste errors
set pastetoggle=<F2>
" use backspace to delete text
set backspace=indent,start,eol
" use auto indentation
set autoindent
set smartindent
" dont user tab chars, use four spaces
set expandtab
set smarttab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set textwidth=0
set wrapmargin=0
set wrap
set linebreak
" scrolling settings
set scrolloff=3
set sidescrolloff=7
set sidescroll=1
" don't make backup file
set nobackup
set nowb
set noswapfile
" the history size
set history=10000
"undoing time
set undodir=~/.vim/undodir
set undofile
set undolevels=1000
set undoreload=10000
"last line info options
set showcmd
" show what mode you are in
set showmode
" cursor position info
set ruler
" show current line number and others relative
set number
set relativenumber
" confirm bash as shell
set shell=/bin/zsh
"IgnoreCase, IncrementedSearch, SmartCaSe
set ignorecase incsearch smartcase
"ShowMatch
set showmatch
set matchtime=2
" auto complete in cmd mode
set wildmenu
set wildmode=full
set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.un~
"speed boosters
set lazyredraw
set ttyfast
" folding
set foldmethod=indent
set nofoldenable
"Always show the status line
set laststatus=2
"statusline
set statusline= " clear the statusline for when vimrc is reloaded
set statusline+=%-3.3n\ " buffer number
set statusline+=%f\ " file name
set statusline+=%h%m%r%w " flags
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%*
set statusline+=%= " right align
set statusline+=%b,0x%-8B\ " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
" quickfix shortcuts
nmap ]q :cnext<CR>
nmap ]Q :clast<CR>
nmap [q :cprev<CR>
nmap [Q :cfirst<CR>
" save file using sudo
cmap w!! w !sudo tee %
"space include spaces
nmap <Space> i<Space><Esc>
" move through split
nnoremap <C-H> <C-w>h
nnoremap <C-L> <C-w>l
nnoremap <C-J> <C-w>j
nnoremap <C-K> <C-w>k
"tab walking
nmap <left> :tabprev<CR>
nmap <right> :tabnext<CR>
nmap <Leader>h :tabprev<CR>
nmap <Leader>l :tabnext<CR>
nmap <Leader>tq :tabclose<CR>
""buffer walking
nmap <Leader>k :bn <CR>zz
nmap <Leader>j :bp <CR>zz
nmap <up> :bn <CR>zz
nmap <down> :bp <CR>zz
"clean highlight search
nmap <C-c> <ESC>:nohlsearch<CR>
"Search
" faz os resultados da busca aparecerem no meio da tela
nmap n nzz
nmap N Nzz
nmap * *zz
nmap # #zz
nmap g* g*zz
nmap g# g#zz
"Dir/files navigation
nmap <Leader>- :Explore<CR>
nmap <Leader>v- :Vexplore<CR>
nmap <Leader>s- :Sexplore<CR>
nmap <Leader>t- :Texplore<CR>
"split
nmap <Leader>v <C-w>v
nmap <Leader>s <C-w>s
nmap <Leader>t :tabnew<CR>
"CtrlP
" let g:ctrlp_cmd = 'CtrlPMixed'
"PyMode
"let g:pymode_options_max_line_length = 100
" let g:pymode_rope_completion = 0
let g:pymode_rope_complete_on_dot = 0
let g:syntastic_python_checker_args = '--ignore=W0611 --ignore=W0401'
" handlerbars ember plugin
let g:mustache_abbreviations=1
" vim-latex
let g:tex_flavor='latex'
nmap <C-f> <plug>IMAP_JumpForward
" save file
nmap <F9> :wa!<CR>
vmap <unique> <up> <Plug>SchleppUp
vmap <unique> <down> <Plug>SchleppDown
vmap <unique> <left> <Plug>SchleppLeft
vmap <unique> <right> <Plug>SchleppRight
vmap <unique> D <Plug>SchleppDup
" undotree
nnoremap <F5> :UndotreeToggle<cr>
" netrw
let g:netrw_banner = 0
if has('nvim')
nmap <BS> <C-W>h
setlocal expandtab
"neovim terminal
tnoremap <Esc> <C-\><C-n>
tnoremap <C-H> <C-\><C-n><C-w>h
tnoremap <C-L> <C-\><C-n><C-w>l
tnoremap <C-J> <C-\><C-n><C-w>j
tnoremap <C-K> <C-\><C-n><C-w>k
endif
"Color
hi Search ctermbg=green ctermfg=black
hi IncSearch ctermbg=black ctermfg=cyan
hi TabLineSel ctermfg=red ctermbg=grey
hi statusline guibg=Cyan ctermfg=6 guifg=Black ctermbg=0
hi MatchParen cterm=bold ctermbg=none ctermfg=3
autocmd BufNewFile,BufRead \*.{md,mdwn,mkd,mkdn,mark\*} set filetype=markdown
augroup BufWritePre_
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
augroup END
augroup Filetype
autocmd!
autocmd FileType gitcommit set tw=72
augroup END
" Put these in an autocmd group, so that we can delete them easily.
augroup BufReadPost_
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
"Cria caminho completo do novo arquivo
function! s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
function! VisualSelection(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment