Skip to content

Instantly share code, notes, and snippets.

@AllanHasegawa
Last active August 29, 2015 14:03
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 AllanHasegawa/34cd40766d01b2504d12 to your computer and use it in GitHub Desktop.
Save AllanHasegawa/34cd40766d01b2504d12 to your computer and use it in GitHub Desktop.
.vimrc
" Space is your leader
let mapleader = "\<Space>"
" My <leader> mappings
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
vmap <leader>y "+y
vmap <leader>d "+d
nmap <leader>p "+p
nmap <leader>P "+P
vmap <leader>p "+p
vmap <leader>P "+P
nnoremap <silent> <leader>t :NERDTree<CR>
nnoremap <silent> <leader>n :set paste<CR>
nnorema <silent> <leader>N :set nopaste<CR>
nnoremap <silent> <leader>s :TagbarToggle<CR>
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>f :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>f :ClangFormat<CR>
" This is the 'c++ identer'. I'm ignoring identation after a namespace
" declaration
set cino=N-s
let g:clang_format#command="clang-format-3.5"
" vim-multiple-cursos
" If set to 0, then pressing "<ESC>" in Insert Mode will not erase all
" cursors.
let g:multi_cursor_exit_from_insert_mode=0
" Default directories
let undodir = expand('~/.undo-vim')
if !isdirectory(undodir)
call mkdir(undodir)
endif
set undodir=~/.undo-vim
set undofile
let swapdir = expand('~/.vim/swap')
if !isdirectory(swapdir)
call mkdir(swapdir)
endif
let backupdir = expand('~/.vim/backup')
if !isdirectory(backupdir)
call mkdir(backupdir)
endif
set t_Co=256
" read .cl files as C files
au BufRead,BufNewFile *.cl setfiletype c
au BufRead,BufNewFile *.ispc setfiletype c
au BufRead,BufNewFile *.isph setfiletype c
au BufRead,BufNewFile *.glsl setfiletype c
" remove auto //-style comments in C/CPP files
filetype plugin indent on
au FileType c,cpp setlocal comments-=:// comments+=f://
" show line numbers
set nu
" tab == 2 spaces
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
" Show invisible characters
set list
set listchars=eol:˼,tab:¬\ ,trail:~,extends:>,precedes:<
" syntax coloring :)
syntax on
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
" backspace can remove chars before the point where insert mode was activated
set backspace=indent,eol,start
"""""""""""""""""""""""""""""""""""""""""""""
" Begin Vundle config
"""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
" 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 'Valloric/YouCompleteMe'
Plugin 'majutsushi/tagbar'
Plugin 'bling/vim-airline'
Plugin 'Lokaltog/powerline-fonts'
Plugin 'flazz/vim-colorschemes'
Plugin 'wting/rust.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'dag/vim2hs'
Plugin 'scrooloose/nerdcommenter'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'tpope/vim-eunuch'
Plugin 'rhysd/vim-clang-format'
Plugin 'http://git.code.sf.net/p/vim-latex/vim-latex'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"""""""""""""""""""""""""""""""""""""""""""""
" End Vundle config
"""""""""""""""""""""""""""""""""""""""""""""
let g:Powerline_symbols="fancy"
let g:airline_theme="luna"
let g:airline_powerline_fonts = 1
set ttimeout
set ttimeoutlen=50 " There is a pause when leaving insert mode
set laststatus=2 "vim-airline doesn't appear until I create a new split
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
let g:airline#extensions#tagbar#enabled = 1
" auto open tagbar
"autocmd VimEnter * nested :call tagbar#autoopen(1)
"autocmd BufEnter * nested :call tagbar#autoopen(0)
let g:tagbar_width = 80
let g:tagbar_autofocus = 1
" column width marker
set colorcolumn=120
" YouCompleteMe options
let g:ycm_add_preview_to_completeopt = 1
""""""""""""""""""""""""""""""""""""""""""""
" Show tab number. From:
" http://vim.wikia.com/wiki/Show_tab_number_in_your_tab_line
"""""""""""""""""""""""""""""""""""""""""""""
if exists("+showtabline")
function MyTabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let s .= i . ')'
let s .= ' %*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let file = bufname(buflist[winnr - 1])
let file = fnamemodify(file, ':p:t')
if file == ''
let file = '[No Name]'
endif
let s .= file
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
set stal=2
set tabline=%!MyTabLine()
endif
"**************************************************
" Latex Configurations
"**************************************************
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
" TIP: if you write your \label's as \label{fig:something}, then if you
" type in \ref{fig: and press <C-n> you will automatically cycle through
" all the figure labels. Very useful!
set iskeyword+=:
let g:Tex_DefaultTargetFormat='pdf'
let g:Tex_ViewRule_dvi='okular'
let g:Tex_ViewRule_pdf='okular'
let g:Tex_CompileRule_dvi='latex --src-specials -interaction=nonstopmode $*'
let g:Tex_CompileRule_pdf='pdflatex -synctex=1 --src-specials -interaction=nonstopmode $*'
let g:Tex_Leader='@'
let g:Tex_MultipleCompileFormats='pdf'
let g:Tex_Folding=0
map <C-y> <Plug>IMAP_JumpForward
map! <C-y> <Plug>IMAP_JumpForward
autocmd BufRead *.tex imap <buffer> ;;l <Plug>Tex_LeftRight
autocmd BufRead *.tex imap <buffer> ;;b <Plug>Tex_MathBF
autocmd BufRead *.tex imap <buffer> ;;c <Plug>Tex_MathCal
autocmd BufRead *.tex imap <buffer> ;;i <Plug>Tex_InsertItemOnThisLine
autocmd BufRead *.tex unmap! <buffer> é
autocmd BufRead *.tex imap <buffer> ũc <Plug>Tex_MathCal
autocmd BufRead *.tex unmap! <buffer> ã
autocmd BufRead *.tex unmap! <buffer> â
" Lets you navigate through 'Display Lines'
" From: http://vim.wikia.com/wiki/VimTip38
" mapping to make movements operate on 1 screen line in wrap mode
"let b:gmove = "yes"
"function! ScreenMovement(movement)
"if &wrap && b:gmove == 'yes'
"return "g" . a:movement
"else
"return a:movement
"endif
"endfunction
"onoremap <silent> <expr> j ScreenMovement("j")
"onoremap <silent> <expr> k ScreenMovement("k")
"onoremap <silent> <expr> 0 ScreenMovement("0")
"onoremap <silent> <expr> ^ ScreenMovement("^")
"onoremap <silent> <expr> $ ScreenMovement("$")
"nnoremap <silent> <expr> j ScreenMovement("j")
"nnoremap <silent> <expr> k ScreenMovement("k")
"nnoremap <silent> <expr> 0 ScreenMovement("0")
"nnoremap <silent> <expr> ^ ScreenMovement("^")
"nnoremap <silent> <expr> $ ScreenMovement("$")
"vnoremap <silent> <expr> j ScreenMovement("j")
"vnoremap <silent> <expr> k ScreenMovement("k")
"vnoremap <silent> <expr> 0 ScreenMovement("0")
"vnoremap <silent> <expr> ^ ScreenMovement("^")
"vnoremap <silent> <expr> $ ScreenMovement("$")
"vnoremap <silent> <expr> j ScreenMovement("j")
"" toggle showbreak
"function! TYShowBreak()
"if &showbreak == ''
"set showbreak=>
"else
"set showbreak=
"endif
"endfunction
"function! TYToggleBreakMove()
"if exists("b:gmove") && b:gmove == "yes"
"let b:gmove = "no"
"else
"let b:gmove = "yes"
"endif
"endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment