Skip to content

Instantly share code, notes, and snippets.

@Soft
Created April 8, 2010 08:25
Show Gist options
  • Save Soft/359900 to your computer and use it in GitHub Desktop.
Save Soft/359900 to your computer and use it in GitHub Desktop.
My .vimrc file
" Soft's .vimrc
" Useful plugins: indent-object, NERD_tree, NERD_commenter, delimitMate,
" snipMate, surround, Command-T, EasyMotion
" Nice colorschemes: Herald, Neverland, Mustang, Molokai
set nocompatible
if has("gui_win32")
source $VIMRUNTIME/mswin.vim
behave mswin
endif
syntax on
set t_Co=256
set background=dark
set number
set nowrap
set ruler
set mouse=a
set mousemodel=popup
set tabstop=4
set shiftwidth=4
set smarttab
set smartindent
set autoindent
set noerrorbells
set visualbell
set t_vb=
set lazyredraw
filetype plugin indent on
set completeopt=longest,menuone,preview
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
function! Tab_Or_Complete()
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
return "\<C-N>"
else
return "\<Tab>"
endif
endfunction
nmap <silent> <C-l> :bnext<CR>
nmap <silent> <C-h> :bprev<CR>
imap jj <Esc>
set laststatus=2
set wildmenu
set foldenable
set hidden
set scrolloff=10
set sidescrolloff=5
set showmatch
let mapleader = ","
if exists("+autochdir")
set autochdir
endif
" Paste
nnoremap <F2> :set invpaste paste?<CR>
imap <F2> <C-0><F2>
set pastetoggle=<F2>
map <F6> :make<CR>
" Search
set ignorecase
set smartcase
set incsearch
set hlsearch
map <silent> <leader>n :nohlsearch<CR>
map <space> /
map <C-space> ?
set history=100
" Arrow keys change buffers and tabs
inoremap <silent> <left> <nop>
inoremap <silent> <right> <nop>
inoremap <silent> <up> <nop>
inoremap <silent> <down> <nop>
noremap <silent> <left> :bprevious<CR>
noremap <silent> <right> :bnext<CR>
noremap <silent> <up> :tabnext<CR>
noremap <silent> <down> :tabprevious<CR>
set encoding=utf-8
noremap <leader>y "+y
noremap <leader>p "+gP
noremap <silent> <leader>v :vsplit<CR>
noremap <silent> <leader>s :split<CR>
noremap H <C-w>h
noremap J <C-w>j
noremap K <C-w>k
noremap L <C-w>l
if has("gui_running")
set guioptions-=T " No toolbar
set guioptions-=t " No tearoff menus
set guioptions+=c
set guifont=Terminus\ 9
if has("gui_win32") || (expand("$TILING_WM") != 1)
set columns=150
set lines=50
endif
if has("autocmd")
autocmd! GuiEnter * set t_vb=
endif
" colorscheme herald
colorscheme solarized
else
colorscheme molokai
cmap w!! w !sudo tee >/dev/null %
endif
if has("statusline")
" Custom status line
set statusline= " clear the statusline for when vimrc is reloaded
set statusline+=%F\ " file name
set statusline+=%-2.2n " buffer
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%h%m%r%w " flags
set statusline+=%= " left/right separator
set statusline+=%c,%l/ " cursor column/total lines
set statusline+=%L\ %P " total lines/percentage in file
endif
" python.vim
let python_highlight_builtins=1
let python_highlight_excepions=1
let python_highlight_string_formatting=1
let python_highlight_string_format=1
let python_highlight_string_templates=1
" NERDCommenter
map \\ <Plug>NERDCommenterInvert
" NERDTree
let NERDTreeIgnore=['\.class$', '\.pyc$', '\~$']
map <silent> <F3> :NERDTreeToggle<CR>
" EasyMotion
let g:EasyMotion_leader_key = '<Leader>m'
" N900 doesn't have physical keys for these
if $OSSO_PRODUCT_FULL_NAME == "Nokia N900"
abbreviate !oc {
abbreviate !cc }
abbreviate !os [
abbreviate !cs ]
abbreviate !ot <
abbreviate !ct >
endif
if has("autocmd")
" Ugly hack but somehow makes it work >_>
autocmd BufRead,BufNewFile * inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>
autocmd BufWritePost $MYVIMRC source $MYVIMRC
autocmd BufRead,BufNewFile *.vala setfiletype vala
autocmd BufRead,BufNewFile *.vapi setfiletype vala
autocmd BufRead,BufNewFile *.scala setfiletype scala
autocmd BufRead,BufNewFile *.json setfiletype javascript
autocmd BufRead,BufNewFile *.pegjs setfiletype javascript
autocmd FileType java silent! compiler javac | setlocal makeprg=javac\ % | setlocal errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment