Skip to content

Instantly share code, notes, and snippets.

@jackfranklin
Created December 8, 2010 17:07
Show Gist options
  • Save jackfranklin/733557 to your computer and use it in GitHub Desktop.
Save jackfranklin/733557 to your computer and use it in GitHub Desktop.
my vimrc file
"
".vimrc File
"Written by Jack Franklin
"A lot of this came from Jeffrey Way's video tutorials & his .vimrc file
"(jeffrey-way.com, net.tutsplus.com)
"
"Tabs
set tabstop=4
set shiftwidth=4
set softtabstop=4
set ts=4
set expandtab
"Turn off annoying sounds
set noerrorbells
set novisualbell
set t_vb=
"Remove RH Scrollbar
if has ("gui_running")
set guioptions-=R "remove right-hand scroll Bar
set guioptions-=r "remove right-hand scroll Bar
set guioptions-=l "remove right-hand scroll Bar
set guioptions-=L "remove right-hand scroll bar
endif
"If CSS file, auto indent stuff inside braces
autocmd FileType css, less set smartindent
"Turn spell checking on/off with ,ss
map ,ss :setlocal spell!<cr>
"Enable Filetypes
filetype on
filetype plugin on
filetype indent on
syntax on
"Shortcut to edit VIMRC in new tab
nmap ,ev :tabedit $MYVIMRC<cr>
"Change Zen-Coding plugin expansion key to cntl+e
let g:user_zen_expandabbr_key = '<C-e>'
"Save old file when switching to new one
set autowrite
"Font and Theme
set guifont=Monaco:h14
colorscheme navajo-night
"Line numbers
set number
"Indents
set smartindent
set autoindent
set copyindent "copy the previous indentation on autoindenting
"Stop Vim making back up files
set nobackup
set noswapfile
"Clear search when you press ,/
nmap <silent> ,/ :nohlsearch<CR>
"Larger Line Height
set linespace=3
"Better wrapping YO YO YO
set wrap
set textwidth=79
set formatoptions=qrnl
"Highlight Searching
set hlsearch
"Case insensitive
set ignorecase
set smartcase
"Hides MacVim toolbar
set go-=T
"Autocompletion menu
set wildmode=list:longest
"Enable Code Folding
set foldenable
"Be quicker - replace : with a space
nmap <space> :
"Automatically change current directory to that of the file in the buffer
autocmd BufEnter * cd %:p:h
"Make auto complete better"
set completeopt=longest,menuone
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
\ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
"Auto save settings without having to reload VIM
autocmd bufwritepost .vimrc source ~/.vimrc
"Nerd Tree
nmap ,nt :NERDTreeToggle
let NERDTreeShowHidden=1
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
"Stop arrow keys working so I have to use hjkl
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
"This means whenever Vim loses focus, it saves the files in the buffer
au FocusLost * :wa
"This sorts CSS properties alphabetically just by typign ,S
nnoremap ,S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
"Dont press escape, press jj
inoremap jj <ESC>
"Don't bother supporting Vi
set nocompatible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment