Skip to content

Instantly share code, notes, and snippets.

@ritsz
Last active January 3, 2018 05:43
Show Gist options
  • Select an option

  • Save ritsz/de7b237359ec7038f9f1e0eaf27bb087 to your computer and use it in GitHub Desktop.

Select an option

Save ritsz/de7b237359ec7038f9f1e0eaf27bb087 to your computer and use it in GitHub Desktop.
syntax on
set encoding=utf-8
set autoindent
set smartindent
set cindent
set tabstop=4
set shiftwidth=4
"set expandtab
set nu
set rnu
set ruler
set laststatus=2
set splitbelow
set backspace=indent,eol,start
set showmatch
set nocscopeverbose
set splitright
set splitbelow
set incsearch " search as characters are entered
set t_Co=256
set background=dark
set hlsearch " highlight matches
set rtp+=$HOME/.local/lib/python3.5/site-packages/powerline/bindings/vim
set foldenable " enable folding
set foldmethod=indent " fold based on indent level
set foldlevel=0
set foldlevelstart=0 "zR to open all folds
set nocompatible
"
" Key mappings
"
" turn off search highlight with , and space
nnoremap <C-\><space> :nohlsearch<CR>
" space open/closes folds
nnoremap <space> za
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>CR
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>CR
nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>CR
nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>CR
nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>CR
nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>CR
nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
"Map space and direction keys to different tabs"
map <C-@><up> :tabr<cr>
map <C-@><down> :tabl<cr>
map <C-@><left> :tabp<cr>
map <C-@><right> :tabn<cr>
" move vertically by visual line
nnoremap j gj
nnoremap k gk
" move to beginning/end of line
nnoremap B ^
nnoremap E $
" $/^ doesn't do anything
nnoremap $ <nop>
nnoremap ^ <nop>
"
" Plugins add here
"
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/nerdtree'
Plugin 'benmills/vimux'
call vundle#end() " required
filetype plugin indent on " required
"
" Set global values
"
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let mapleader = ","
"
"Commands
"
command Compile execute "!python ~/compile.py %"
map <F5> :Compile<CR>
function! LoadCscope()
let db = findfile("cscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/cscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
" else add the database pointed to by
" environment variable
" elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
endfunction
au BufEnter /* call LoadCscope()
"
" Mapping filetypes
"
au BufRead,BufNewFile *.rs set filetype=rust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment