Skip to content

Instantly share code, notes, and snippets.

@csghone
Last active August 18, 2022 09:45
Show Gist options
  • Select an option

  • Save csghone/d0259c7831a022f4e418926abcf9f75b to your computer and use it in GitHub Desktop.

Select an option

Save csghone/d0259c7831a022f4e418926abcf9f75b to your computer and use it in GitHub Desktop.
Minmal vimrc
" If startup is slow - change clipboard options
" Show line/row/col numbers
set showcmd " This should be before nocompatible or nocp
set nu
set ruler
set laststatus=2
set incsearch
set history=10000
" Filetype and Synatx Highlighting
filetype on " Automatically detect file types
filetype indent on " Filetype specific indentation
filetype plugin on
set fileencodings= " don't do any encoding conversion (otherwise munges binary files)
syntax on " Syntax Highlighting
set foldlevel=100 " Default all folds open
" Allow clipboard copy-paste 'sudo apt-get install xsel' before this step
set clipboard^=unnamed " Yanks go on clipboard
set clipboard^=unnamedplus " Yanks go on clipboard
" set clipboard=exclude:.* " If startup is slow, comment upper two lines and uncomment this one
" Avoids random characters when using tmux/screen/byobu
" Alternate approach is update tmux/byobu using https://launchpad.net/~byobu/+archive/ubuntu/ppa
set guicursor=
" Tabs and Indentation
set expandtab
set smarttab
set smartindent " smart indent of code - indent after opening '{',
set autoindent " Copy indent from current line when starting a new line
set shiftwidth=4 " Number of spaces to use for each step of (auto)indent
set tabstop=4 " Number of spaces that a <Tab> in the file counts for.
set softtabstop=4 " Backspace the proper number of spaces
set shiftround " Round indent to multiple of 'shiftwidth'
" Change tab behaviour based on filetype - cc=vertical column postition
autocmd FileType c,cpp,h,hpp,cxx setlocal cc=81 | setlocal shiftwidth=2 | setlocal tabstop=2 | setlocal softtabstop=2 | set noic
autocmd FileType python setlocal cc=81
autocmd FileType conque_term setlocal nolist
autocmd FileType xml,json setlocal foldmethod=indent | setlocal shiftwidth=2 | setlocal tabstop=2 | setlocal softtabstop=2 | set noic
" Default scheme is meh
colorscheme torte
" To use Ctrl-Right/Left to switch to next words
map <C-Left> b
map <C-Right> e
imap <C-Right> <esc>ea
imap <C-Left> <esc>bi
" To use Ctrl-Right/Left to switch to next words in BYOBU/TMUX/SCREEN
if &term =~ '^screen'
" tmux will send xterm-style keys when its xterm-keys option is on
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif
" Jump to next/prev functions in python using [[ or ]]
autocmd FileType python nnoremap <buffer> [[ ?^class\\|^\s*def<CR>
autocmd FileType python nnoremap <buffer> ]] /^class\\|^\s*def<CR>
" See whitespace - commented by default as it messes up Putty
" set listchars=tab:»\ ,nbsp:\ ,trail:»
" set list
" Un-comment to enable scrolling in vim
" set mouse=a
" To easily search string with '/'
" https://vim.fandom.com/wiki/Searching_for_expressions_which_include_slashes
command! -nargs=1 Ss let @/ = <q-args>
command! -nargs=1 SS let @/ = '\V'.escape(<q-args>, '\')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment