Skip to content

Instantly share code, notes, and snippets.

@giladno
Last active December 16, 2018 09:28
Show Gist options
  • Save giladno/64a4519b42746c9c50f47f53e1e4b020 to your computer and use it in GitHub Desktop.
Save giladno/64a4519b42746c9c50f47f53e1e4b020 to your computer and use it in GitHub Desktop.
My .vimrc file
set autoindent
set autoread " Make Vim automatically open changed files
set background=dark
" set cinoptions=:0,(s,u0,U1
set clipboard=unnamed
set colorcolumn=120
set columns=130
set copyindent
set cursorline
set directory^=$HOME/.vim/swp//
set encoding=utf-8
set expandtab
if exists('&guifont')
set guifont=Courier\ New:h14
endif
set guioptions-=r
set guioptions-=R
set guioptions-=l
set guioptions-=L
set hidden
set history=1000
set hlsearch
set ignorecase
set incsearch
set isfname-=: " ignore colon in go-file gf
set laststatus=2
set lazyredraw
set linebreak "Wrap lines at convenient points
set matchtime=0 " zero blink time on close-match: so vim will be fast
set mouseshape=n:beam
set nobackup
set nocompatible " be iMproved, required
set noswapfile
set nowrap "Don't wrap lines
set number
set sessionoptions+=resize,winpos
set shiftwidth=2 " no. of spaces for step in autoindent
set showmatch
set signcolumn=yes
set smartcase
set smartindent
set smarttab
set softtabstop=2 " no. of spaces for tab when editing
set statusline+=%F\ %l\:%c
set synmaxcol=256 " syntax coloring of huge lines slows the world
set t_Co=256
set tabstop=2 " no. of spaces for tab in file
set timeoutlen=500 " shared keys macros timeout: we should not have any!
set updatetime=250
set wildignore=**/node_modules,.git,**/build
set wildmenu
syntax on
au FileType javascript setlocal sw=4 et
vnoremap . :norm.
if has("gui_running")
autocmd VimEnter * set guitablabel=%N:\ %t\ %M
end
if has("gui_macvim")
" Switch to specific tab numbers with Command-number
for i in range(1, 9)
execute printf('noremap <D-1> :tabn %d<CR>', i)
endfor
" Command-0 goes to the last tab
noremap <D-0> :tablast<CR>
:set macmeta
endif
filetype off " required
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 0
"let g:gitgutter_sign_column_always = 1
let g:gitgutter_map_keys = 0
let g:jsx_ext_required = 0
let g:ctrlp_by_filename = 1
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<2-LeftMouse>'],
\ 'AcceptSelection("t")': ['<cr>'],
\ }
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_working_path_mode = 'ra'
if executable('ag')
let g:ackprg = 'ag --vimgrep'
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
endif
let g:UltiSnipsSnippetsDir=$HOME."/.vim_snippets"
let g:UltiSnipsSnippetDirectories=[$HOME."/.vim_snippets", "UltiSnips"]
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" let g:UltiSnipsUsePythonVersion = 2
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.jsx,*.js'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.js'
let g:deoplete#enable_at_startup = 1
let g:deoplete#sources#ternjs#types = 1
let g:deoplete#sources#ternjs#depths = 1
let g:deoplete#sources#ternjs#docs = 0
let g:deoplete#sources#ternjs#filter = 0
let g:deoplete#sources#ternjs#case_insensitive = 1
let g:deoplete#sources#ternjs#guess = 1
let g:deoplete#sources#ternjs#sort = 0
let g:deoplete#sources#ternjs#expand_word_forward = 0
let g:deoplete#sources#ternjs#omit_object_prototype = 1
let g:deoplete#sources#ternjs#include_keywords = 1
let g:deoplete#sources#ternjs#in_literal = 0
let g:deoplete#sources#ternjs#filetypes = ['jsx']
let mapleader=' '
let NERDTreeQuitOnOpen = 1
let NERDTreeAutoDeleteBuffer = 1
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let NERDTreeMapOpenInTab = '<ENTER>'
let NERDTreeChDirMode = 2
let g:used_javascript_libs = 'underscore,react'
let g:AutoPairsShortcutToggle = ''
let g:AutoPairsMultilineClose = 1
map <C-n> :NERDTreeToggle<CR>
nnoremap <silent> <Leader>f :NERDTreeFind<CR>
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'itchyny/lightline.vim'
Plugin 'ctrlp.vim'
Plugin 'flazz/vim-colorschemes'
" Plugin 'pangloss/vim-javascript'
" Plugin 'jelera/vim-javascript-syntax'
Plugin 'othree/yajs.vim'
Plugin 'othree/es.next.syntax.vim'
Plugin 'mxw/vim-jsx'
Plugin 'Tuxdude/mark.vim'
Plugin 'giladno/vmark.vim--Visual-Bookmarking'
Plugin 'airblade/vim-gitgutter'
Plugin 'ReplaceWithRegister'
Plugin 'mileszs/ack.vim'
Plugin 'othree/html5.vim'
Plugin 'othree/html5-syntax.vim'
Plugin 'othree/javascript-libraries-syntax.vim'
Plugin 'w0rp/ale'
Plugin 'alvan/vim-closetag'
"Plugin 'SirVer/ultisnips'
Plugin 'Auto-Pairs'
Plugin 'scrooloose/nerdtree'
Plugin 'mechatroner/rainbow_csv'
"Plugin 'yankstack'
"Plugin 'moll/vim-node'
"Plugin 'Shougo/deoplete.nvim'
"Plugin 'roxma/nvim-yarp'
"Plugin 'roxma/vim-hug-neovim-rpc'
"Plugin 'carlitux/deoplete-ternjs'
" Plugin 'css-color-preview'
Plugin 'KabbAmine/vCoolor.vim'
Plugin 'hashivim/vim-terraform'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
au BufRead,BufNewFile *.ejs set filetype=html
" nnoremap <leader><space> :noh<cr>
nnoremap gf <C-W>gf
cnoreabbrev Ack Ack!
cnoreabbrev e tabedit
nmap <D-F> :Ack<space>
nmap <Leader><space> <Plug>MarkSet
" map / <Plug>(incsearch-forward)
" map ? <Plug>(incsearch-backward)
colorscheme luna
" Cancel a search with Escape
nnoremap <silent> <Esc> :nohlsearch<Bar>:echo<CR>
" When editing a file, always jump to the last cursor position
au BufReadPost * call Cursor_to_last_position()
function! Cursor_to_last_position()
if line("'\"") && line("'\"") <= line("$")
exe "normal `\""
endif
endfunction
au BufNewFile * setlocal notx expandtab
" Save/Load session based on current directory
function! MakeSession()
let b:sessiondir = $HOME."/.vim/sessions".getcwd()
if (filewritable(b:sessiondir)!=2)
exe 'silent !mkdir -p ' b:sessiondir
redraw!
endif
let b:filename = b:sessiondir.'/session.vim'
exe "mksession! " . b:filename
endfunction
function! LoadSession()
let b:sessiondir = $HOME."/.vim/sessions".getcwd()
let b:sessionfile = b:sessiondir."/session.vim"
if (filereadable(b:sessionfile))
exe 'source ' b:sessionfile
else
echo "No session loaded."
endif
endfunction
if(argc()==0)
au VimEnter * nested :call LoadSession()
endif
au VimLeave * :call MakeSession()
" Highlighttrailing whitespaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Setup file explorer
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
set autochdir
set splitbelow
set splitright
map vv <C-W>v
map ss <C-W>s
map Q <C-W>q
" map <C-E> :Lexplore<CR>
" Ctrl-J to navigate between panes
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Disable F1
:map! <F1> <nop>
for i in range(1, 12)
execute printf(':imap <F%d> <nop>', i)
execute printf(':imap <S-F%d> <nop>', i)
execute printf(':imap <M-F%d> <nop>', i)
execute printf(':imap <D-F%d> <nop>', i)
endfor
" Clear search buffer using ,/
nmap <silent> ,/ :nohlsearch<CR>
" Map F1 to search online
function! OnlineDoc()
let s:urlTemplate = "https://www.google.com/search?q=%"
let s:browser = "open"
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(s:urlTemplate, "%", s:wordUnderCursor, "g")
let s:cmd = "silent! !" . s:browser . " " . s:url
execute s:cmd
endfunction
map <F1> :call OnlineDoc()<CR>
" Reload .vimrc
:nmap <Leader>s :source $MYVIMRC<CR>
" Highlight last inserted text
nnoremap gV `[v`]
" Specific syntax for special files
augroup filetypedetect
au BufRead,BufNewFile .eslintrc,.babelrc set filetype=json
augroup END
if has('persistent_undo')
silent !mkdir ~/.vim/backups > /dev/null 2>&1
set undodir=~/.vim/backups
set undofile
endif
" Auto indent pasted text
nnoremap p p=`]<C-o>
nnoremap P P=`]<C-o>
" Move normally between wrapped lines
nmap j gj
nmap k gk
vnoremap p "_dP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment