Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created January 24, 2012 09:29
Show Gist options
  • Save fjolnir/1669242 to your computer and use it in GitHub Desktop.
Save fjolnir/1669242 to your computer and use it in GitHub Desktop.
let mapleader = ","
set nocompatible
set backspace=indent,eol,start
set number
set ruler
syntax on
set encoding=utf-8
set wildmenu
set hidden " Allow buffers to go into the background without writing
set history=1000 " Remember the last 1000 command
set shortmess=atI " Get rid of annoying alerts
set visualbell " Silence the bell
set title " Set the title of the terminal window
set timeoutlen=400 " Quick timeout for key combos
set ttyfast " Faster redraw
set lazyredraw
" Exclude character under cursor when selecting
" set selection=exclusive
" Whitespace stuff
set nowrap
set list listchars=tab:\ \ ,trail:·
set textwidth=120
" Quickly expand or collapse the current fold.
:nnoremap <space> za
" Wrapping (Break on word)
function! ToggleWrap()
if &wrap
set nowrap
else
set showbreak=…
set wrap linebreak" nolist
endif
endfunction
map <Leader>w :call ToggleWrap()<CR>
call ToggleWrap() " Wrap by default
" Undo settings
if v:version >= 703
"undo settings
set undodir=~/.vim/undofiles
set undofile
endif
" Statusline setup
set statusline=%f "tail of the filename
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
set statusline+=%h "help file flag
"set statusline+=%y "filetype
set statusline+=%r "read only flag
set statusline+=%m "modified flag
set statusline+=%{fugitive#statusline()}
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
" Tab completion
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/bundle/**
" Status bar (Always show)
set laststatus=2
" Enable modelines
set modeline
" Directories for swp files
set backupdir=~/.vim/backup
set directory=~/.vim/backup
" MacVIM shift+arrow-keys behavior (required in .vimrc)
let macvim_hig_shift_movement = 1
" Show (partial) command in the status line
set showcmd
" Make scrolling begin before we reach the edge
set scrolloff=8 "Start scrolling when we're 8 lines away from margins
set sidescrolloff=15
set sidescroll=1
" Highlight the current line
set cursorline
hi CursorLine cterm=NONE ctermbg=0 " Lightens the current line a bit
" Speed up the scroll keys
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" ----------- Plugins
call pathogen#infect()
" CTags&Taglist
let Tlist_Ctags_Cmd="/usr/local/bin/ctags"
map <Leader>rt :!/usr/local/bin/ctags --extra=+f -R *<CR><CR>
map <C-\> :tnext<CR>
let Tlist_Compact_Format = 1
let Tlist_Enable_Fold_Column = 0
let Tlist_Exit_OnlyWindow = 1
let Tlist_WinWidth = 35
let Tlist_Use_Right_Window=1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Display_Tag_Scope = 1
let Tlist_Process_File_Always = 1
let Tlist_Show_One_File = 0
let Tlist_Auto_Higlight_Tag = 1
let Tlist_File_Fold_Auto_Close = 1
let Tlist_Inc_Winwidth = 1
let tlist_objc_settings = 'ObjectiveC;M:Macros;P:Protocols;i:Interfaces;p:Properties;m:Instance methods'
let tlist_php_settings = 'php;c:class;f:Functions'
map <Leader>tl :TlistToggle<CR>
" Command-T configuration
let g:CommandTMaxHeight=20
" ZoomWin configuration
map <Leader><Leader> :ZoomWin<CR>
map <leader>f :CommandT<CR>
" gist-vim defaults
if has("mac")
let g:gist_clip_command = 'pbcopy'
elseif has("unix")
let g:gist_clip_command = 'xclip -selection clipboard'
endif
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
" Nerd tree
let NERDTreeIgnore=['\.pyc$', '\.rbc$', '\~$']
let NERDTreeMouseMode=2
let NERDTreeDirArrows=1
let NERDTreeMinimalUI=1
map <Leader>n :NERDTreeToggle<CR>
" Indenting
set tabstop=4
set shiftwidth=4
set softtabstop=4
set noexpandtab
set noautoindent smartindent
set nojoinspaces
" Append modeline after last line in buffer. (<leader>ml)
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d :",
\ &tabstop, &shiftwidth, &textwidth)
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
" Display tabs&trailing spaces
set list
set listchars=tab:▸⋅,trail:⋅,nbsp:⋅
" Enable code folding based on indent
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=1
" Notes settings
let g:notes_directory = "~/Dropbox/PlainText/Tasks"
let g:notes_suffix = ".md"
" Git (Fugitive)
map <Leader>gs :Gstatus<CR>
map <Leader>gc :Gcommit<CR>
map <Leader>gb :Gblame<CR>
map <Leader>gd :Gdiff HEAD<CR>
map <Leader>ge :Gedit<CR> " Return to editing work file from historic buffer
" Conqueterm
map <Leader>ts :ConqueTermSplit zsh<cr>
map <Leader>tv :ConqueTermVSplit zsh<cr>
map <Leader>tt :ConqueTermTab zsh<cr>
" Tab switching
map <C-t>k :tabl<cr>
map <C-t>j :tabr<cr>
map <C-t>h :tabp<cr>
map <C-t>l :tabn<cr>
imap <C-t>k <Esc>:tabl<cr>
imap <C-t>j <Esc>:tabr<cr>
imap <C-t>h <Esc>:tabp<cr>
imap <C-t>l <Esc>:tabn<cr>
" Window switching
nmap <C-l> <C-W>l
nmap <C-h> <C-W>h
nmap <C-j> <C-W>j
nmap <C-k> <C-W>k
imap <C-l> <Esc><C-W>l
imap <C-h> <Esc><C-W>h
imap <C-j> <Esc><C-W>j
imap <C-k> <Esc><C-W>k
" Window resizing
nmap <C-S-Up> <C-W>+
nmap <C-S-Down> <C-W>-
nmap <C-S-Left> <C-W><
nmap <C-S-Right> <C-W>>
" Gundo
nnoremap <F5> :GundoToggle<CR>
let g:gundo_right=1
" --- Filetype support stuff
filetype on
" Enable syntastic syntax checking
let g:syntastic_enable_signs=1
let g:syntastic_quiet_warnings=1
" Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set ft=ruby
" add json syntax highlighting
au BufNewFile,BufRead *.json set ft=javascript
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
" Little bit of Xcode integration
function! ActivateApp(appName)
call system("osascript -e 'tell application \"".a:appName."\" to activate'")
endfunction
function! ClickMenuItemInApp(appName, menuName, menuItemName)
call system("osascript -e 'tell application \"".a:appName."\" to activate'"
\ ." -e 'tell application \"System Events\"'"
\ ." -e 'tell process \"".a:appName."\" to click menu item \"".a:menuItemName."\" of menu \"".a:menuName."\" of menu bar 1'"
\ ." -e 'end tell'")
endfunction
au FileType objc nmap <silent> <C-R> :call ClickMenuItemInApp('Xcode', 'Product', 'Run')<CR>
au FileType objc nmap <silent> <C-B> :call ClickMenuItemInApp('Xcode', 'Product', 'Build')<CR>
au FileType objc nmap <silent> <C-@> :call ActivateApp('Xcode')<CR>
au FileType objc imap <silent> <C-R> <Esc>:call ClickMenuItemInApp('Xcode', 'Product', 'Run')<CR>
au FileType objc imap <silent> <C-B> <Esc>:call ClickMenuItemInApp('Xcode', 'Product', 'Build')<CR>
au FileType objc imap <silent> <C-@> <Esc>:call ActivateApp('Xcode')<CR>
" --- Hacks
" Without setting this, ZoomWin restores windows in a way that causes
" equalalways behavior to be triggered the next time CommandT is used.
" This is likely a bludgeon to solve some other issue, but it works
set noequalalways
" load the plugin and indent settings for the detected filetype
filetype indent on
filetype plugin on
" Load snippet support functions
source ~/.vim/snipmate-snippets/support_functions.vim
" Mouse mode & clipboard sharing (Terminal version)
set clipboard=unnamed
set mouse=a
colorscheme solarized
set background=dark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment