Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Created August 23, 2017 19:50
Show Gist options
  • Save peteristhegreat/eacb5aa8fdf0108bd01d88f75a1407fe to your computer and use it in GitHub Desktop.
Save peteristhegreat/eacb5aa8fdf0108bd01d88f75a1407fe to your computer and use it in GitHub Desktop.
Another vimrc file
execute pathogen#infect()
set nocp
filetype plugin on
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/cpp
" set tags+=~/.vim/tags/gl
" set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4
set tags+=~/.vim/tags/sys_time
" build tags of your own project with Ctrl-F12
map <C-F6> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
" 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"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
function! SuperCleverTab()
if strpart(getline('.'), 0, col('.') - 1) =~ '^\s*$'
return "\<Tab>"
else
if &omnifunc != ''
return "\<C-X>\<C-O>"
elseif &dictionary != ''
return "\<C-K>"
else
return "\<C-N>"
endif
endif
endfunction
" Make it so I can open a new tab and start editing a file in one short
" command
command! -nargs=1 E :tabnew <bar> e <args>
" Compile and open the error window in one go, by pressing F5
map <F5> :make <bar> copen<cr><cr>
" inoremap <Tab> <C-R>=SuperCleverTab()<cr>
set whichwrap+=<,>,h,l,[,]
set ls=2
set sessionoptions-=options
set sessionoptions+=tabpages,blank,buffers,curdir,folds,help,winsize
" make tabs look like 3 spaces, but still use tab characters
"set noexpandtab
"set copyindent
"set preserveindent
"set softtabstop=0
"set shiftwidth=3
"set tabstop=3
filetype plugin indent on
set expandtab
"set copyindent
"set preserveindent
set softtabstop=3
set shiftwidth=3
set tabstop=3
" show line numbers
set number
" Change the mapleader from \ to ,
let mapleader=","
" let maplocalleader="\\"
let python_highlight_all = 1
let python_slow_sync = 0
set showcmd
inoremap jj <ESC>
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
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 matches as you type
set pastetoggle=<F2>
imap <F5> <C-o>:setlocal spell! spelllang=en_us<CR>
" setlocal spell spelllang=en_us
set mouse=a
" enable fuzzy searching when :CtrlP <foldername> is typed
set runtimepath^=~/.vim/bundle/ctrlp.vim
" disable arrow keys
" Use the damn hjkl keys
noremap <up> <nop>
noremap <down> <nop>
noremap <left> <nop>
noremap <right> <nop>
" provide hjkl movements in Insert mode via the <Alt> modifier key
inoremap <A-h> <C-o>h
inoremap <A-j> <C-o>j
inoremap <A-k> <C-o>k
inoremap <A-l> <C-o>l
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
" Easier tab navigation
autocmd VimEnter * tab all
" autocmd BufAdd * exe 'tablast | tabe "' . expand( "<afile") .'"'
nnoremap H gT
nnoremap L gt
nnoremap <A-F1> 1gt
nnoremap <A-F2> 2gt
nnoremap <A-F3> 3gt
nnoremap <A-F4> 4gt
nnoremap <A-F5> 5gt
nnoremap <A-F6> 6gt
nnoremap <A-F7> 7gt
nnoremap <A-F8> 8gt
nnoremap <A-F9> 9gt
nnoremap <A-F0> 10gt
" noremap <M-LeftMouse> <LeftMouse><Esc><C-V>
" noremap <M-LeftDrag> <LeftDrag>
set t_Co=256
" Enable Solarized Colors
let g:solarized_termtrans=1
let g:solarized_termcolors=256
set rtp+=~/.vim/bundle/vim-colors-solarized
syntax enable
set background=dark
colorscheme solarized
highlight Comment ctermfg=247
highlight Operator ctermfg=254
" highlight LineNr ctermfg=657B83 ctermbg=000000
hi Folded ctermbg=000000
hi TabLineFill ctermfg=657B83 ctermbg=000000
hi TabLineSel ctermfg=657B83 ctermbg=none
" hi TabLineSel ctermfg=LightGreen ctermbg=DarkGreen
set smartcase " makes most searches case insensitive without needing to add \c to it
set virtualedit=onemore
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Watch for changes to vimrc and autoreload
" http://superuser.com/questions/132029/how-do-you-reload-your-vimrc-file-without-restarting-vim
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
" enable clipbard to copy to global
set guioptions+=a
" set clipboard=unnamedplus " only works on v7.3.74+
function! ShowFunc(sort)
let gf_s = &grepformat
let gp_s = &grepprg
if ( &filetype == "c" || &filetype == "php" || &filetype == "python" ||
\ &filetype == "sh" )
let &grepformat='%*\k%*\sfunction%*\s%l%*\s%f %m'
let &grepprg = 'ctags -x --'.&filetype.'-types=f --sort='.a:sort
elseif ( &filetype == "perl" )
let &grepformat='%*\k%*\ssubroutine%*\s%l%*\s%f %m'
let &grepprg = 'ctags -x --perl-types=s --sort='.a:sort
elseif ( &filetype == "vim" )
let &grepformat='%*\k%*\sfunction%*\s%l%*\s%f %m'
let &grepprg = 'ctags -x --vim-types=f --language-force=vim --sort='.a:sort
endif
if (&readonly == 0) | update | endif
silent! grep %
cwindow 10
redraw
let &grepformat = gf_s
let &grepprg = gp_s
endfunc
noremap <F3> <Esc>:call ShowFunc("no")<CR><Esc>
noremap <S-F3> <Esc>:call ShowFunc("yes")<CR><Esc>
autocmd BufWrite * call SetStatusLine()
autocmd BufRead * call SetStatusLine()
function! SetStatusLine()
set statusline=[%n]\ %f\ %(\ \ (%M%R%H)%)\ \ \ %=\t%{ShowTab()}\ \ \ Modified:\ %{Time()}\ \ [%3l:%3L,%2c]\ %p%%\
endfunction
function! Time()
return strftime("%c", getftime(bufname("%")))
endfunction
function! ShowTab()
let TabLevel = (indent('.') / &ts )
if TabLevel == 0
let TabLevel='*'
endif
return TabLevel
endfunction
fun! ShowFuncName()
echoh1 ModeMsg
" echo getline(search("^ [^ \t#/]\\{2}.*[\s]*$", 'bWn'))
echo getline(search("^[^#/][\s]*def .*[\s]*$", 'bWn'))
echoh1 None
endfun
map f :call ShowFuncName() <CR>
"let g:netrw_banner = 0
"let g:netrw_liststyle = 3
"let g:netrw_browse_split = 4
"let g:netrw_altv = 1
"let g:netrw_winsize = 25
"augroup ProjectDrawer
"autocmd!
"autocmd VimEnter * :Vexplore
"augroup END
" let g:NERDCustomDelimiters = { 'c': { 'left': '// ', 'right': '' } }
" For moving lines (^] is a special character; use <M-k> and <M-j> if it works)
"nnoremap k mz:m-2<CR>`z==
"inoremap j <Esc>:m+<CR>==gi
"inoremap k <Esc>:m-2<CR>==gi
"vnoremap j :m'>+<CR>gv=`<my`>mzgv`yo`z
"nnoremap j mz:m+<CR>`z==
"vnoremap k :m'<-2<CR>gv=`>my`<mzgv`yo`z
nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment