Skip to content

Instantly share code, notes, and snippets.

@adamphillips
Last active January 18, 2022 13:57
Show Gist options
  • Save adamphillips/f95a52548ca6ee12789d64a7d31e670e to your computer and use it in GitHub Desktop.
Save adamphillips/f95a52548ca6ee12789d64a7d31e670e to your computer and use it in GitHub Desktop.
Example .vimrc
syntax on
filetype plugin on
" Enable autocomplete
set ofu=syntaxcomplete#Complete
" General defaults
" ===================
set expandtab " use spaces for tabs
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set backspace=indent,eol,start
" allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set smartindent " copy the previous indentation on autoindenting
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set shiftwidth=2 " 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 title " change the terminal's title
set nobackup
set noswapfile
" Allows toggling into paste mode
set pastetoggle=<F2>
" Spell checking
" ===================
" Enable spell checking. F6 to turn on, F7 to turn off again
map <F6> <Esc>:setlocal spell spelllang=en_gb<CR>
map <F7> <Esc>:setlocal nospell<CR>
:set spellfile=~/.vim/dict.add
" Formatting
" ===================
" Use Q for formatting the current paragraph (or selection)
" This means that shift+q will auto wrap in both visual and normal modes
vmap Q gq
nmap Q gqap
" Quick alignment of text
nnoremap <leader>al :left<CR>
nnoremap <leader>ar :right<CR>
nnoremap <leader>ac :center<CR>
" Show leading whitespace that includes spaces, and trailing whitespace.
":autocmd BufWinEnter * match ExtraWhitespace /\s+$/
" Commit editing
" ===================
" Custom function to toggle actions when interactively rebasing
function RebaseActionToggle()
let line = getline(".")
let result = matchstr(line, "^\\a")
let transitions = {'p': 'squash', 's': 'edit', 'e': 'fixup', 'f': 'reword', 'r' : 'pick'}
execute "normal! ^cw" . transitions[result]
execute "normal! ^"
endfunction
autocmd FileType gitrebase map <Cr> :call RebaseActionToggle()<Cr>
autocmd FileType gitcommit setlocal spell spelllang=en_gb
" Colours
" ===================
hi LineNr ctermfg=240 ctermbg=234
" Syntax highlighting
" ===================
" Highlight adp files as HTML
au BufRead,BufNewFile {*.adp} set filetype=html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment