Skip to content

Instantly share code, notes, and snippets.

@dnshl
Created June 2, 2019 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnshl/33033523165602b9456fc1ded532f788 to your computer and use it in GitHub Desktop.
Save dnshl/33033523165602b9456fc1ded532f788 to your computer and use it in GitHub Desktop.
vimrc
" Use vim settings, rather then vi settings (much better!)
" This must be first, because it changes other options as a side effect.
set nocompatible
filetype off " required for vundle
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'ctrlpvim/ctrlp.vim'
"Plugin 'tomasr/molokai'
Plugin 'nanotech/jellybeans.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'scrooloose/nerdtree'
Plugin 'mattn/emmet-vim'
Plugin 'itchyny/lightline.vim'
" UltiSnipsStart
" Track the engine.
Plugin 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
Plugin 'Trevoke/ultisnips-rspec'
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" UltiSnipsEnd
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" UI "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax on "color highlighting
set number "line numbers
set is "incremental search
"set background=dark "background dark/light
colorscheme jellybeans
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ }
"colorscheme solarized
set noshowmode
set colorcolumn=81
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Behavior "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set title " change the terminal's title
set titleold=""
set fileformats="unix,dos,mac"
set wildmenu " make tab completion for files/buffers act like bash
" Backup files
set noswapfile
" tabs
set tabstop=2
set shiftwidth=2
set expandtab
set ruler "shows line and column number
set laststatus=2 "shows statusline
set hidden
set list " Show invisible characters
set listchars=tab:›\ ,eol:¬,trail:⋅ " Set the characters for the invisibles
" MacVim
if has("gui_running")
set guioptions=egmrt "diable toolbar
set gfn=Menlo:h14 "set font
colorscheme molokai
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remappings "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader="," "change leader to ,
" NERDTree
map <leader>d :NERDTreeToggle<CR>
"reload configuration
noremap <F5> :execute 'so $MYVIMRC'<CR>
" Easy window navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
nnoremap <leader>w <C-w>v<C-w>l "split pane horizontal and set focus
" list buffers
"nnoremap <C-l> :execute 'ls'<CR>
" Rotate Buffers
nnoremap <Tab> :execute 'bn'<CR>
nnoremap <S-Tab> :execute 'bp'<CR>
nnoremap <leader>k :execute 'bn'<CR>
nnoremap <leader>h :execute 'bp'<CR>
"die buffer die
nnoremap <C-t> :execute 'bd'<CR>
" remove empty lines at end of file
" %s/\($\n\s*\)\+\%$//e
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
" NERDTree
let NERDTreeShowBookmarks=1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto Commands "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufWritePre * :%s/\s\+$//e " Remove trailing whitespaces on write
function TrimWhiteSpace()
%s/\s\+$//e
echo "Trailing whitespace stripped\n"
endfunction
map <F2> :call TrimWhiteSpace()<CR>
map! <F2> :call TrimWhiteSpace()<CR>
" line numbering
autocmd FocusLost * :set number
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
autocmd CursorMoved * :set relativenumber
" " Cycle through relativenumber + number, number (only), and no numbering.
" " function! mappings#cycle_numbering() abort
" function! Cycle_numbering() abort
" if exists('+relativenumber')
" execute {
" \ '00': 'set relativenumber | set number',
" \ '01': 'set norelativenumber | set number',
" \ '10': 'set norelativenumber | set nonumber',
" \ '11': 'set norelativenumber | set number' }[&number . &relativenumber]
" else
" " No relative numbering, just toggle numbers on and off.
" set number!<CR>
" endif
" endfunction
" Folding
"autocmd BufWinLeave * mkview " save folds automatically
"autocmd BufWinEnter * silent loadview " load folds automatically
" CtrlP
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
"nnoremap <F8> :call GetDate('')<CR>
function! GetDate(format)
let format = empty(a:format) ? '+%A %Y-%m-%d %H:%M UTC' : a:format
let cmd = '/bin/date -u ' . shellescape(format)
let result = substitute(system(cmd), '[\]\|[[:cntrl:]]', '', 'g')
" Append space + result to current line without moving cursor.
call setline(line('.'), getline('.') . ' ' . result)
endfunction
nnoremap <F8> :call GetReleaseNotes('')<CR>
function! GetReleaseNotes(tag)
"let format = empty(a:format) ? '$(git describe --abbrev=0)' : a:format
let tag = system('git describe --abbrev=0')
let cmd = '$(/usr/local/bin/git log --pretty=format:%s ' . shellescape(tag) . '..HEAD)'
"let result = substitute(system(cmd), '[\]\|[[:cntrl:]]', '', 'g')
" Append space + result to current line without moving cursor.
"call setline(line('.'), getline('.') . ' ' . result)
execute '$read !'. cmd
endfunction
" Fix indentation
map <F7> mzgg=G`z<CR>
" delete all html tags
" :%s/<\([^>]*\)>//g
" macros
" Transforms:
" %div{ class: 'col-md-6' }
" Into:
" %div.col-md-6
"
let @c="0f{df'i.f'd$0j"
let @x="0f%df'i.f'd$0j"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment