Skip to content

Instantly share code, notes, and snippets.

@alesegdia
Created November 19, 2014 21:41
Show Gist options
  • Save alesegdia/c5e097a8528a1e64203d to your computer and use it in GitHub Desktop.
Save alesegdia/c5e097a8528a1e64203d to your computer and use it in GitHub Desktop.
My little dirty .vimrc
"http://nvie.com/posts/how-i-boosted-my-vim/
" load plugins
call pathogen#infect()
set guifont=Consolas\ 10
set nocp
filetype on
filetype plugin on
filetype plugin indent on
syntax on
set autochdir
"let g:clang_user_options = "-std=c++11 -stdlib=libc++ -I./core/assets/ -I./**"
"colorscheme Mustang_Vim_Colorscheme_by_hcalves
"let g:syntastic_cpp_compiler = 'clang++'
"let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
"
"au BufNewFile,BufRead *.cpp set syntax=cpp11
"
" Clang Complete Settings
let g:clang_use_library=1
let g:clang_debug=1
let g:clang_library_path='/usr/lib/llvm-3.5/lib'
" if there's an error, allow us to see it
let g:clang_complete_copen=1
let g:clang_complete_macros=1
let g:clang_complete_patterns=0
" Limit memory use
let g:clang_memory_percent=70
" Remove -std=c++11 if you don't use C++ for everything like I do.
let g:clang_user_options=' -std=c++11 || exit 0'
" Set this to 0 if you don't want autoselect, 1 if you want autohighlight,
" and 2 if you want autoselect. 0 will make you arrow down to select the first
" option, 1 will select the first option for you, but won't insert it unless you
" press enter. 2 will automatically insert what it thinks is right. 1 is the most
" convenient IMO, and it defaults to 0.
let g:clang_auto_select=1
set conceallevel=2
set concealcursor=vin
let g:clang_snippets=1
let g:clang_conceal_snippets=1
" The single one that works with clang_complete
let g:clang_snippets_engine='clang_complete'
"set omnifunc=syntaxcomplete#Complete
" OmniCppComplete
"let OmniCpp_NamespaceSearch = 1
"let OmniCpp_GlobalScopeSearch = 1
"let OmniCpp_ShowAccess = 1
"let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
"let OmniCpp_MayCompleteDot = 1 " autocomplete after .
"let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
"let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
"au BufNewFile,BufRead,BufEnter *.cpp,*.hpp,*.h set omnifunc=omni#cpp#complete#Main
"ruby
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
"autocmd FileType text,markdown let b:vcm_tab_complete = 'dict'
" improve autocomplete menu color
highlight Pmenu ctermbg=238 gui=bold
" enable glsl syntax highlight
au BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl setf glsl
set number
set foldmethod=syntax
nnoremap <M-n> o<Esc>
nnoremap <M-N> o<BS><BS><Esc>
inoremap <F9> <C-O>za
nnoremap <F9> za
onoremap <F9> <C-C>za
vnoremap <F9> zf
nnoremap <silent> <Space> za
" @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" tabs vim-like
nnoremap th :tabfirst<CR>
nnoremap tj :tabnext<CR>
nnoremap tk :tabprev<CR>
nnoremap tl :tablast<CR>
nnoremap tt :tabedit<Space>
nnoremap tn :tabnext<Space>
nnoremap tm :tabm<Space>
" nnoremap td :tabclose<CR>
" tabs firefox-like
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 <C-Insert> :tabnew<CR>
nnoremap <C-Delete> :tabclose<CR>
nnoremap <F12> :make<cr>:cwindow<cr>
inoremap <F12> :make<cr>:cwindow<cr>
set splitbelow
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
"settings
set nowrap " don't wrap lines
set tabstop=4 " a tab is four spaces
set backspace=indent,eol,start
" allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
"set number " always show line numbers
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set pastetoggle=<F8>
" build tags of your own project with Ctrl-F12
map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
"keys
" switch .h .cpp
map <F1> :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
" save
nmap <F2> :w!<cr>
imap <F2> <esc>:w!<cr>li
" go to definition of function
map <F3> <C-]>
map <F4> :TagbarToggle<cr>
nmap <F5> :NERDTree<cr>
nmap <C-f> :FufFile<cr>
imap <C-f> <esc>:FufFile<cr>
nmap <C-b> :FufBuffer<cr>
nmap <F7> :Dox<cr>
" map <C-space> :TlistToggle
map <C-k> :bnext <CR>
map <C-j> :bprevious <CR>
map <C-M-s> <esc> :w! <cr>
" C-w C-w switch window
" gt gT navigate through tabs
" =i{ indent everything
" ctrl + t ->, ctrl + d <-
" select region, = or ==
" gg=G
" 1gg0vG$
" gg=G -> =<cr>
"doc function
map <C-d> \cfu <cr>
if bufwinnr(1)
vmap <kPlus> <C-W>>
vmap <kMinus> <C-W><
endif
"whitespaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Disable valadoc syntax highlight
"let vala_ignore_valadoc = 1
" Enable comment strings
let vala_comment_strings = 1
" Highlight space errors
let vala_space_errors = 1
" Disable trailing space errors
"let vala_no_trail_space_error = 1
" Disable space-tab-space errors
let vala_no_tab_space_error = 1
" Minimum lines used for comment syncing (default 50)
"let vala_minlines = 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment