Skip to content

Instantly share code, notes, and snippets.

@ZenToad
Created October 20, 2021 14:01
Show Gist options
  • Save ZenToad/527ce303df12324c74f99bbd9774390c to your computer and use it in GitHub Desktop.
Save ZenToad/527ce303df12324c74f99bbd9774390c to your computer and use it in GitHub Desktop.
vimrc Oct 2021
set encoding=utf-8
""""""""""""""""""""""""""""""""""""""""""
" Vundle Plugin
""""""""""""""""""""""""""""""""""""""""""
" set the runtime path to include Vundle and initialize
set rtp+=$HOME/vimfiles/bundle/Vundle.vim/
call vundle#begin('$HOME/vimfiles/bundle/')
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'preservim/nerdcommenter'
Plugin 'ycm-core/YouCompleteMe'
Plugin 'easymotion/vim-easymotion'
Plugin 'ludovicchabant/vim-gutentags'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'Raimondi/delimitMate'
Plugin 'mileszs/ack.vim'
Plugin 'danro/rename.vim'
Plugin 'majutsushi/tagbar'
Plugin 'rafi/awesome-vim-colorschemes'
Plugin 'junegunn/limelight.vim' " Highlights only active paragraph
Plugin 'junegunn/goyo.vim' " Full screen writing mode
Plugin 'reedes/vim-pencil'
Plugin 'vimwiki/vimwiki'
Plugin 'itchyny/lightline.vim'
Plugin 'Valloric/ListToggle'
Plugin 'zah/nim.vim'
call vundle#end()
""""""""""""""""""""""""""""""""""""""""""
" vimwiki
""""""""""""""""""""""""""""""""""""""""""
let wiki = {}
let wiki.path = '$HOME\\vimwiki'
let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'}
let g:vimwiki_list = [wiki]
""""""""""""""""""""""""""""""""""""""""""
" YouCompleteMe
""""""""""""""""""""""""""""""""""""""""""
" Disable the ycm preivew popup window
"set completeopt-=preview
"let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_always_populate_location_list = 1
let g:ycm_auto_hover = ''
""""""""""""""""""""""""""""""
" NERDTree toggle
""""""""""""""""""""""""""""""
inoremap <C-K><C-B> <ESC>:NERDTreeToggle<CR>
nnoremap <C-K><C-B> <ESC>:NERDTreeToggle<CR>
""""""""""""""""""""""""""""""
" CTRL-P
""""""""""""""""""""""""""""""
let g:ctrlp_working_path_mode = 0
map <leader>f :CtrlP<cr>
let g:ctrlp_max_height = 20
let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee'
""""""""""""""""""""""""""""""
" Delimit Mate
""""""""""""""""""""""""""""""
" Expand braces
let delimitMate_expand_cr=1
""""""""""""""""""""""""""""""
" nerdcommenter Mate
""""""""""""""""""""""""""""""
let g:NERDSpaceDelims = 1
let g:NERDDefaultAlign = 'left'
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ack searching and cope displaying
" requires ack.vim - it's much better than vimgrep/grep
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use the the_silver_searcher if possible (much faster than Ack)
if executable('ag')
let g:ackprg = 'ag --vimgrep --smart-case'
endif
" Close search results
let g:ack_mappings = {'O': '<CR>:ccl<CR>'}
" Search for word under cursor
nnoremap <F3> :Ack <c-r>=expand("<cword>") <CR><CR>
" Open Ack and put the cursor in the right position
map <leader>g :Ack
" Do :help cope if you are unsure what cope is. It's super useful!
"
" When you search with Ack, display your results in cope by doing:
" <leader>cc
"
" To go to the next search result do:
" <leader>n
"
" To go to the previous search results do:
" <leader>p
"
"map <leader>cc :botright cope<cr>
"map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
"map <leader>n :cn<cr>
"map <leader>p :cp<cr>
" Make sure that enter is never overriden in the quickfix window
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
""""""""""""""""""""""""""""""""""""""""""
" Tagbar
""""""""""""""""""""""""""""""""""""""""""
nmap <F9> :TagbarOpen fj<CR>
""""""""""""""""""""""""""""""""""""""""""
" Goyo
""""""""""""""""""""""""""""""""""""""""""
nmap <F11> :Goyo<CR>
""""""""""""""""""""""""""""""""""""""""""
" Limelight
""""""""""""""""""""""""""""""""""""""""""
nmap <F10> :Limelight!!<CR>
""""""""""""""""""""""""""""""""""""""""""
" ListToggle
""""""""""""""""""""""""""""""""""""""""""
" let g:lt_location_list_toggle_map = '<F10>'
" let g:lt_quickfix_list_toggle_map = '<F11>'
let g:lt_height = 10
nmap <F5> :lprevious<CR>
nmap <F6> :lnext<CR>
nmap <F7> :cprevious<CR>
nmap <F8> :cnext<CR>
""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""
let mapleader=","
set nocompatible "be iMproved
" Let Window's Alt keys work
set winaltkeys=yes
" Sets how many lines of history VIM has to remember
set history=500
" Enable filetype plugins
filetype indent plugin on
" Set to auto read when a file is changed from the outside
set autoread
""""""""""""""""""""""""""""""""""""""""""
" VIM user interface
""""""""""""""""""""""""""""""""""""""""""
" No annoying sound on errors
set belloff=all
" tab complete and stuff
set path+=**
set wildmenu
"Always show current position
set ruler
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Show line numbers
set nu
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Add a bit extra margin to the left
set foldcolumn=1
if has("gui_running")
set guioptions-=T "Remove toolbar
set guioptions-=m "Remove menubar
set guicursor+=a:blinkon0 " disable blinking cursor
endif
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
set hlsearch
endif
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
""""""""""""""""""""""""""""""""""""""""""
" Key mappings
""""""""""""""""""""""""""""""""""""""""""
" Windows Cut/Paste keys
source $VIMRUNTIME/mswin.vim
" REQUIRED
imap jk <C-Esc>
nnoremap ; :
nnoremap q; q:
nnoremap <SPACE> o<ESC>
" (f)ull (s)creen
nnoremap <leader>fs :simalt ~x<CR>
" (r)estor (s)creen
nnoremap <leader>rs :simalt ~r<CR>
" Better editing of my vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Toggle word wrap
nnoremap <silent> <leader>w :set nowrap!<CR>
" Turn search highlight off
nnoremap <leader>/ :nohl<CR>
" Move around windows
nnoremap <C-H> <C-W>h
nnoremap <C-J> <C-W>jkk
nnoremap <C-K> <C-W>k
nnoremap <C-L> <C-W>l
" Open new tab
nnoremap <silent> <C-T> :tabnew<CR>
" Move lines up/down with Alt jk
nnoremap <silent> <A-j> :m .+1<CR>==
nnoremap <silent> <A-k> :m .-2<CR>==
inoremap <silent> <A-j> <Esc>:m .+1<CR>==gi
inoremap <silent> <A-k> <Esc>:m .-2<CR>==gi
vnoremap <silent> <A-j> :m '>+1<CR>gv=gv
vnoremap <silent> <A-k> :m '<-2<CR>gv=gv
" vertical split same file
nnoremap <leader>vs <ESC>:vsplit<CR>
" Don't use Ex mode, use Q for formatting
map Q gq
" Remap VIM 0 to first non-blank character
map 0 ^
""""""""""""""""""""""""""""""""""""""""""
" Colors and Fonts
""""""""""""""""""""""""""""""""""""""""""
syntax enable
set background=dark
colorscheme focuspoint
" colorscheme solarized
" colorscheme scheakur
if has("gui_running")
set t_Co=256
set guifont=Consolas:h10
" zoom.vim
source $HOME/vimfiles/plugin/zoom.vim
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git etc anyway...
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set lbr
set tw=500
"set tw=80
"set linespace=3
set ai "Auto indent
set si "Smart indent
set nowrap "Wrap lines
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Programming
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" autorun build script
"--------------------------------------------------------------
" game-brain
"--------------------------------------------------------------
" nnoremap <silent> <leader>m :below call term_start('build\game_brain_build.bat', {'hidden': 0})<CR>
nnoremap <silent> <leader>m :below call term_start('build\build_polyline_test.bat', {'hidden': 0})<CR>
"--------------------------------------------------------------
" unit testing
"--------------------------------------------------------------
" nnoremap <silent> <leader>m :below call term_start('build\test.bat', {'hidden': 0})<CR>
"--------------------------------------------------------------
" Testing
"--------------------------------------------------------------
" nnoremap <silent> <leader>m :below call term_start('backendbuild.bat', {'hidden': 0})<CR>
"--------------------------------------------------------------
" Sandbox
"--------------------------------------------------------------
" nnoremap <silent> <leader>t :call term_start('build\sdl_module_dll.bat', {'hidden': 1})<CR>
" nnoremap <silent> <leader>m :below call term_start('build\sdl_module_dll.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>g :below call term_start('build\sdl_sandbox.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>m :below call term_start('build\sdl_sandbox.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>b :below call term_start('build\deploy_sdl_sandbox.bat', {'hidden': 0})<CR>
"--------------------------------------------------------------
" Dirk is sys
"--------------------------------------------------------------
" nnoremap <silent> <leader>t :call term_start('build\build_dis_game.bat', {'hidden': 1})<CR>
" nnoremap <silent> <leader>m :below call term_start('build\build_dis_game.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>g :below call term_start('build\build_dis_main.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>m :below call term_start('build\build_dis_main.bat', {'hidden': 0})<CR>
"--------------------------------------------------------------
" Gamedev
"--------------------------------------------------------------
" nnoremap <silent> <leader>t :call term_start('build\cbr_game_dll.bat', {'hidden': 1})<CR>
" nnoremap <silent> <leader>m :below call term_start('build\cbr_game_dll.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>g :below call term_start('build\cbr_win32.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>b :below call term_start('build\deploy_cbr_win32.bat', {'hidden': 0})<CR>
" nnoremap <silent> <leader>m :below call term_start('build\cbr_win32.bat', {'hidden': 0})<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
endif
return ''
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment