Skip to content

Instantly share code, notes, and snippets.

@thom-nic
Created June 5, 2014 13:53
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 thom-nic/bd8bf40538c5ee5ac5ca to your computer and use it in GitHub Desktop.
Save thom-nic/bd8bf40538c5ee5ac5ca to your computer and use it in GitHub Desktop.
Vim files
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
source ~/.vimrc
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = ''
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
silent execute '!diff -a ' . opt . v:fname_in . ' ' . v:fname_new . ' > ' . v:fname_out
endfunction
set acd
set guioptions-=T
" Change the 'desert' colorscheme slightly
"colorscheme desert " this is already set in .vimrc!
hi Normal guibg=grey10
" default window size:
set lines=45 columns=97
"___________KEY MAPPINGS_______________
"close an unsaved buffer (only in normal mode):
map <C-S-B> :bd! "Hit return to close buffer.
"This will close a saved buffer:
"map <C-b> :bd<CR>
"This does the same from insert mode.
map! <C-b> <ESC>:bd<CR><insert>
"go to the next buffer:
map <C-j> :bnext<CR>
map! <C-j> <ESC><C-j><insert>
"go to the previous buffer:
map <C-k> :bprev<CR>
map! <C-k> <ESC><C-k><insert>
"same buffer nav mappings w/ up/down arrow keys (redundant):
map <C-down> :bn<CR>
map! <C-down> <ESC><C-down><insert>
map <C-up> :bp<CR>
map! <C-up> <ESC><C-up><insert>
"go to the last buffer (alternate):
map <C-TAB> :b #<CR>
map! <C-TAB> <ESC><C-TAB><INSERT>
"navigate tabs (Vim7) works w/ C-PgUP and C-PgDN
map <C-`> :tabr<CR>
map! <C-`> <ESC>:tabr<CR><INSERT>
"open a new tab:
map <C-T> :tabe<CR>
map! <C-T> <ESC><C-T><CR><INSERT>
"This will convert text to lowercase
"map <C-F> u
"typical windows find keystroke:
"map <C-F> :promptfind<CR>
"map! <C-F> <ESC><C-F><INSERT>
"most IDEs use Ctrl-Space for autocomplete/intellisense.
"insert mode only
map! <C-SPACE> <C-N>
map! <C-S-SPACE> <C-P>
"open a new buffer for editing
map <F2> :enew<CR>
map! <F2> <ESC><F2><INSERT>
"find next: (repeat last find- spans multiple editing sessions)
map <F3> /<CR>
map! <F3> <ESC>l<F3><INSERT>
"un-highlight last searched for text:
map /// :let @/ = ""<CR>
map! <C-F3> <ESC><C-F3><INSERT>
" Pressing < or > will let you indent/unident selected lines
vnoremap < <gv
vnoremap > >gv
"This allows it to work from insert mode. Yip-ee.
imap <F5> <ESC><F5>
imap <F6> <ESC><F6>
"toggle line wrapping:
map <F8> :call ToggleWrap()<CR>
map! <F8> <ESC><F8><INSERT>
function ToggleWrap()
set wrap!
if &wrap
set go-=b
else
set go+=b
endif
echo &wrap ? 'wrap' : 'nowrap'
endfunc
"F12 toggles wrap (Thanks to Alexandre Moreira)
nnoremap <silent> <F12> :call ToggleWrap()<CR>
vnoremap <silent> <F12> <C-C>:call ToggleWrap()<CR>
inoremap <silent> <F12> <C-O>:call ToggleWrap()<CR>
"___________CUSTOM MENU OPTIONS___________________
"Add a seperator and a command to the File menu to open _vimrc (this file).
an 10.332 &File.-SEP0- <Nop>
an 10.333 &File.Open\ &\.vimrc :e $HOME/.vimrc<CR>
an 10.334 &File.Open\ Vim\ &Tips :e $HOME/vimfiles/vimtips.txt<CR>
"Add a command in the help menu to open a browser to www.vim.org
"an 9999.100 &Help.Visit\ v&im\.org :silent! !start C:\progra~1\intern~1\iexplore.exe http://www.vim.org<CR>
"Thom's .vimrc!
"
"this sets the tabs to 4 spaces
set ts=2 sw=2
au FileType ruby setl sw=2 ts=2 et
au FileType python setl sw=4 ts=4 et
au FileType coffee setl sw=2 ts=2 et
"set word wrap to wrap at the end of a word instead of character.
set lbr
"set auto/smart/copy current indent scheme.
set ai si ci
"turn off backup so that "filename.ext~" files aren't written all over.
set nobackup writebackup
set fileformat=unix
"this will allow switching buffers w/o saving in between.
set hidden
"when doing a /something/ search, ignore case unless upper/mixed case is used
set ignorecase smartcase
"use my colors in vimfiles/colors
"colorscheme earthen
colorscheme desert
"folding: (don't usually want this enabled by default).
set foldmethod=indent
set nofoldenable
set foldlevel=99 "when folds are enabled they are left open.
"set foldcolumn=2
"scroll options: keep 1 line visible above & below cursor when scrolling
set so=1
"sidescroll options:
set siso=3
"put this char at the beginning of a wrapped line:
set sbr=*
"jumps to search word as you type (annoying but excellent)
set incsearch
"tab complete now ignores these
set wildignore+=*.o,*.obj,*.bak,*.exe,*.class,*~
"set silent (no beep) - actually the flash is annoying, don't use.
"set vb t_vb=".
"Maki GUI File Open use current directory
set browsedir=buffer
"change to directory of current file automatically
"au BufEnter * lcd %:p:h
"because pathogen is great: https://github.com/tpope/vim-pathogen
execute pathogen#infect()
# sensible turns on undo, which I don't like
set noundofile
syntax on
filetype plugin indent on
au BufRead,BufNewFile *.less setf css
au BufRead,BufNewFile *.scss setf css
au BufRead,BufNewFile Gemfile* setf ruby
au BufRead,BufNewFile *.ru setf ruby
au BufRead,BufNewFile Rakefile setf ruby
au BufRead,BufNewFile Vagrantfile setf ruby
au BufRead,BufNewFile *.md setf markdown
au BufRead,BufNewFile *.json setf javascript
au BufRead,BufNewFile *.ino setf cpp
au! BufRead,BufNewFile *.x68 setf asm68k
au! BufRead,BufNewFile *.vb setf vb
au! BufRead,BufNewFile *.pde setf c
" setting this var will make .prg files use FoxPro highlighting
let filetype_prg = "foxpro"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment