Skip to content

Instantly share code, notes, and snippets.

@evantishuk
Created February 27, 2012 21:18
Show Gist options
  • Select an option

  • Save evantishuk/1927169 to your computer and use it in GitHub Desktop.

Select an option

Save evantishuk/1927169 to your computer and use it in GitHub Desktop.
syntax on
filetype on
" spaces instead of tabs
" prefer 2 spaces
set softtabstop=2
set tabstop=2
set shiftwidth=2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Syntax Files
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" jade syntax highlights
au BufRead,BufNewFile *.jade,*.jade set filetype=jade
au! Syntax jade source /home/etishuk/.vim/syntax/jade.vim
au BufRead,BufNewFile *.php,*.php set filetype=php
au! Syntax php source /home/etishuk/.vim/syntax/php.vim
au BufRead,BufNewFile *.sass,*.sass set filetype=sass
au! Syntax sass source /home/etishuk/.vim/syntax/sass.vim
au BufRead,BufNewFile *.scss,*.scss set filetype=scss
au! Syntax scss source /home/etishuk/.vim/syntax/scss.vim
au BufRead,BufNewFile *.haml,*.haml set filetype=haml
au! Syntax haml source /home/etishuk/.vim/syntax/haml.vim
let &t_SI .= "\e[3 q"
let &t_EI .= "\e[1 q"
" Detect Indent
autocmd BufReadPost * :DetectIndent
let g:detectindent_preferred_expandtab = 1
let g:detectindent_preferred_indent = 2
" Pathogen
call pathogen#infect()
" gist
let g:gist_clip_command = 'xclip -selection clipboard'
let g:github_user = 'evantishuk'
let g:github_token = 'ba2b068b7fe45b6d88c6d85095ffa418'
" Remap arrow keys to keep from cheating
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set so=7 " Set 7 lines to the curors - when moving vertical..
set wildmenu "Turn on WiLd menu
set ruler "Always show current position
set cmdheight=2 "The commandbar height
set hid "Change buffer - without saving
set backspace=indent,eol,start " make backspace work as expected
set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
set hlsearch "Highlight search things
set incsearch "Make search act like search in modern browsers
set nolazyredraw "Don't redraw while executing macros
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" List characters
set listchars=trail:.,tab:██,eol:·
highlight SpecialKey guifg=red ctermfg=black cterm=none
" highlight current line
set cursorline
hi CursorLine cterm=none ctermbg=black ctermfg=none guibg=darkred guifg=white
" tab colors
hi TabLine ctermfg=red ctermbg=black cterm=none guifg=red guibg=black gui=none
hi TabLineSel ctermfg=red ctermbg=black cterm=bold guifg=black guibg=white gui=bold
hi TabLineFill ctermfg=red ctermbg=white cterm=none guifg=black guibg=white gui=none
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable "Enable syntax hl
set encoding=utf8
try
lang en_US
catch
endtry
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment