Skip to content

Instantly share code, notes, and snippets.

@jenikm
Created October 10, 2014 14:54
Show Gist options
  • Save jenikm/0379d9e7d40dd6336f3d to your computer and use it in GitHub Desktop.
Save jenikm/0379d9e7d40dd6336f3d to your computer and use it in GitHub Desktop.
.vimrc
set nocompatible " be iMproved
filetype off " required!
"set rtp+=~/.vim/bundle/vundle/
"call vundle#rc()
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'tpope/vim-rails'
Plugin 'dbext.vim'
Plugin 'derekwyatt/vim-scala'
Plugin 'ctrlp.vim'
Plugin 'fugitive.vim'
Plugin 'vim-ruby/vim-ruby'
Plugin 'kana/vim-textobj-user'
Plugin 'nelstrom/vim-textobj-rubyblock'
Bundle "pangloss/vim-javascript"
Plugin 'mxw/vim-jsx'
runtime macros/matchit.vim
Plugin 'Align'
" THIS CRASHES VIM, fast way to run spec
"Plugin 'skwp/vim-iterm-rspec'
Plugin 'tpope/vim-endwise'
Plugin 'rking/ag.vim'
Plugin 'jmcomets/vim-pony'
Plugin 'ignatov/kotlin-vim'
Plugin 'kchmck/vim-coffee-script'
Plugin 'Lokaltog/vim-easymotion'
"Plugin 'hsanson/vim-android'
call vundle#end() " required
filetype plugin indent on
au BufRead,BufNewFile *.kt set filetype=kotlin
au BufRead,BufNewFile *.jet set filetype=kotlin
au Syntax kotlin source ~/.vim/syntax/kotlin.vim
set laststatus=2
set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
"map q :
let g:EasyMotion_leader_key = ','
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': [],
\ 'AcceptSelection("t")': ['<cr>', '<c-m>'],
\ }
map <D-r> :RunItermSpecLine<cr>
let g:ctrlp_custom_ignore = {'dir': 'vendor'}
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
if has("gui_running")
colorscheme slate
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
au FileType python set sw=2 ts=2 expandtab softtabstop=2
set softtabstop=2
set sw=2
set ts=2
set background=dark
set expandtab
set nu
set hlsearch
set autoindent
set tabpagemax=100
set incsearch
"set pastetoggle=<F3>
set colorcolumn=100
set nocp
set wildignore+=*tmp/*,*.so,*.swp,*.zip,*doc/*
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
"Highlights stuff in red
"nnoremap , :mat Error "<C-R><C-W>"<CR>
" Ag mapping
au BufRead *.rb nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
au BufRead *.erb nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
au BufRead *.haml nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
au BufRead *.js nnoremap K :Ag "\b<C-R><C-W>\b"<CR>:cw<CR> app spec lib db config
nnoremap \ :Ag -l <SPACE>
"Postgres
au BufRead */psql.edit.* set syntax=sql
au BufRead *.pss set syntax=vb
au BufRead *.ru set syntax=ruby
au BufRead *.csv set syntax=nothing
au BufRead *.gradle set syntax=groovy
"au BufRead *.pde set syntax=java
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
"iab pry require 'pry';binding.pry
iab pryr require 'pry-remote';binding.pry_remote
iab pry require 'pry';binding.pry
iab pdb pdb.set_trace()
autocmd FileType javascript iab fu function
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
"Map commands to save and make c file quickly
au BufRead *.c nmap <c-k> :w <bar> make <CR>
au BufRead *.h nmap <c-k> :w <bar> make <CR>
map te :tabedit<Space>
set backspace=indent,eol,start
map tr :call ResolveTask() <CR>
function! ResolveTask()
let task = expand("<cword>")
let cmd = 'resolve_task ' . task
let result = substitute(system(cmd), '[\]\|[[:cntrl:]]', '', 'g')
" Append space + result to current line without moving cursor.
call setline(line('.'), getline('.') . ' ' . result)
endfunction
map <F2> :.w !pbcopy<CR><CR>
map <F3> :r !pbpaste<CR>
autocmd FileType ruby map <F9> :w<CR>:!ruby -c %<CR>
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
set spelllang=en,ru
" Open tag in new tab
nmap <C-\> <C-w><C-]><C-w>T
" Close window
":nmap <C-Q> :q<CR>
" Write
":nmap <C-Q> :q<CR>
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
autocmd BufWritePre *.rb :call TrimWhiteSpace()
autocmd BufWritePre *.js :call TrimWhiteSpace()
autocmd BufWritePre *.haml :call TrimWhiteSpace()
autocmd BufWritePre *.erb :call TrimWhiteSpace()
autocmd BufWritePre *.rjs :call TrimWhiteSpace()
autocmd BufWritePre *.java :call TrimWhiteSpace()
autocmd BufWritePre *.jsx :call TrimWhiteSpace()
let g:ycm_collect_identifiers_from_tags_files = 0
let g:ycm_min_num_of_chars_for_completion = 2
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_complete_in_comments_and_strings=1
let g:ycm_filetype_specific_completion_to_disable = { 'ruby': ['.'] }
let g:ycm_filetype_blacklist = {
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'text' : 1,
\ 'yaml' : 1,
\ 'unite' : 1,
\}
" PostgreSQL
let g:dbext_default_profile_dev = 'type=PGSQL'
let g:dbext_default_profile_slave = 'type=PGSQL'
let g:dbext_default_profile = 'slave'
" For SQL formatting SQLUFormatter
let g:sqlutil_keyword_case = '\U'
let g:sqlutil_align_comma = 1
"syntax off
"au VimEnter * syntax on
"1) Find hexa value of that non-printable character. Move your cursor to that character and press 'ga'.
"2) In escape mode, execute this ':%s/\%x85/\r/g'. In my case, hexadecimal value of that non-printable character is 85. I replaced that with '\r'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment