Skip to content

Instantly share code, notes, and snippets.

@pidb
Created September 8, 2021 23:40
Show Gist options
  • Save pidb/826e537f59071719d6a241ceb9ae1d78 to your computer and use it in GitHub Desktop.
Save pidb/826e537f59071719d6a241ceb9ae1d78 to your computer and use it in GitHub Desktop.
My vimrc
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
Plug 'rhysd/vim-clang-format'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'
" Initialize plugin system
call plug#end()
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" Start NERDTree and leave the cursor in it.
autocmd VimEnter * NERDTree
" clang-format
let g:clang_format#style_options = {
\ "AccessModifierOffset" : -4,
\ "AllowShortIfStatementsOnASingleLine" : "true",
\ "AlwaysBreakTemplateDeclarations" : "true",
\ "Standard" : "C++11",
\ "BreakBeforeBraces" : "Stroustrup"}
let g:clang_format#code_style = 'google'
" map to <Leader>cf in C++ code
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>cf :ClangFormat<CR>
" Toggle auto formatting:
nmap <Leader>C :ClangFormatAutoToggle<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment