Skip to content

Instantly share code, notes, and snippets.

@petrsnd
Created September 14, 2016 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrsnd/6f8403589bec3ea72c4753c95b71db4d to your computer and use it in GitHub Desktop.
Save petrsnd/6f8403589bec3ea72c4753c95b71db4d to your computer and use it in GitHub Desktop.
VIM resource file
" Configuration file for vim
set modelines=0 " CVE-2007-2438
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set backspace=2 " more powerful backspacing
syntax on " syntax highlighting
filetype plugin on " use the file type plugins
:autocmd FileType c,cpp,cxx,cc,h set formatoptions=croql
\ cindent comments=sr:/*,mb:\ *,ex:*/,://
set ts=4 " tab stops = 4
set sw=4 " shift width = 4
set autoindent " copy indent from previous line
set expandtab " insert spaces for tabs
set smarttab " make <TAB> and <BACKSPACE> smarter
set smartindent " make autoindenting handle { and }
set showmatch " show matching bracket
set incsearch " realtime searching
set hlsearch " highlight the last searched term
set history=100 " keep 100 lines of history
set ruler " show the cursor position
set number " line numbers
set numberwidth=5 " line number columns
set pastetoggle=<F2> " Easy toggle for pasting in code
" Toggle line numbers
:nmap <F3> :set invnumber<CR>
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup
" CTags
set tags+=tags;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment