Skip to content

Instantly share code, notes, and snippets.

@coderek
Last active October 6, 2017 20:06
Show Gist options
  • Save coderek/cae309505b453af1cedf28ff59803fbf to your computer and use it in GitHub Desktop.
Save coderek/cae309505b453af1cedf28ff59803fbf to your computer and use it in GitHub Desktop.
vimrc for windows
set nocompatible " be iMproved, required
set rtp+=$HOME/.vim/bundle/Vundle.vim
filetype off " required
" set the runtime path to include Vundle and initialize
call vundle#begin('$HOME/.vim/bundle/')
" 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 'scrooloose/syntastic'
Plugin 'xolox/vim-misc'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'mattn/emmet-vim'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'altercation/vim-colors-solarized'
Plugin 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'elzr/vim-json'
Plugin 'justincampbell/vim-railscasts'
Plugin 'vim-scripts/python.vim'
Plugin 'jdkanani/vim-material-theme'
Plugin 'mileszs/ack.vim'
Plugin 'groenewege/vim-less'
Plugin 'NLKNguyen/papercolor-theme'
Plugin 'honza/vim-snippets'
Plugin 'moll/vim-bbye'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'SirVer/ultisnips'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'airblade/vim-gitgutter'
Plugin 'kshenoy/vim-signature'
Plugin 'joshdick/onedark.vim'
Plugin 'leafgarland/typescript-vim'
Plugin 'OrangeT/vim-csharp'
" All of your Plugins must be added before the following line
call vundle#end() " required
syntax on
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
set number
set history=700
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
set nolist
set listchars=tab:>-,trail:-
" Add a bit extra margin to the left
set foldcolumn=1
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
set noeol
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set noexpandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set nolbr
set textwidth=0
set wrapmargin=0
set ai "Auto indent
set smartindent " No Smart indent
" \*/src,
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,
\*/dashboard/static,
\*/my_django/static,
\*.pyc,*.log,
\*.less.css,
\*.class,
\*/dist,
\*_jst.js,
\*-templates.js,
\*/__pycache__,
\*.pg_dump,
\*/.frontend_tests,
\*/coverage,
\*/target
let g:ctrlp_custom_ignore = 'node_modules\|build\|dist\|bower_components'
let g:vim_markdown_folding_disabled=1
let g:ctrlp_by_filename=1
autocmd FileType html,css,jsx,jinja EmmetInstall
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" indent json files on save
" autocmd BufWritePre *.json %!python -m json.tool
set diffopt=vertical
set cursorline
set colorcolumn=100
let NERDTreeIgnore=[]
let NERDTreeShowBookmarks = 1
let NERDTreeRespectWildIgnore = 1
let NERDTreeChDirMode = 2
let g:ctrlp_open_new_file = 'v'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
let g:ctrlp_max_depth = 10
let g:ctrlp_working_path_mode = 0
set nowrap
nnoremap <Leader>cd :cd %:p:h<CR>
let g:easy_align_delimiters = {
\ '<': { 'pattern': '<-' },
\ '"': { 'pattern': '"' },
\ }
set foldmethod=indent
set foldlevel=99
vnoremap // y/<C-R>"<CR>
nnoremap <Leader><Leader> :vsplit $MYVIMRC<cr>
set splitright
set splitbelow
let g:syntastic_html_tidy_blocklevel_tags = ['paper-toolbar', 'paper-icon-button', 'paper-menu-button', 'paper-menu', 'paper-item', 'paper-drawer-panel', 'paper-header-panel', 'dom-module']
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute "]
nnoremap <Leader>q :Bdelete<CR>
nnoremap <Leader>qa :bufdo :Bdelete<CR>
nnoremap <Leader>c :SyntasticCheck flake8<CR>
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = {
\ "mode": "active",
\ "active_filetypes": ["python"],
\ "passive_filetypes": ["java", "javascript"] }
let g:syntastic_ignore_files = ['\m^/usr/include/', '\m\c\.h$', 'interview/src/py']
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_error_symbol = "?"
let g:syntastic_warning_symbol = "?"
let g:syntastic_javascript_eslint_exec = "./node_modules/.bin/eslint"
let g:javascript_enable_domhtmlcss = 1
autocmd BufReadPre **/migrations/** SyntasticReset
function! Dashboard()
NERDTreeFromBookmark dashboard
endfunction
command! LC edit /Users/derekzeng/Dev/my/random/leetcode.py
" search word under cursor without jumping to next
nnoremap * *##*
function! EditDotFile()
let file_name=$HOME . '/.' . input('Edit .')
exe 'edit' file_name
endfunction
nnoremap <leader>nc :NERDTreeClose<CR>
nnoremap <leader>nl :nohlsearch<CR>
nnoremap <leader>. :call EditDotFile()<CR>
" Put underline for searched terms
highlight Search cterm=underline gui=underline
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2
autocmd FileType htmldjango setlocal foldmethod=indent filetype=javascript
autocmd FileType python setlocal foldmethod=indent cindent nosmartindent
autocmd FileType coffee setlocal tabstop=2 shiftwidth=2
au BufNewFile,BufRead *.es6 set filetype=javascript
au BufNewFile,BufRead *.hbs set filetype=html
au BufNewFile,BufRead *.jst set filetype=html
let g:signify_vcs_list = [ 'git' ]
let g:ackhighlight = 1
" ctrl slash
au BufRead *.md setlocal nonu wrap textwidth=80
au BufRead *.ts setlocal filetype=typescript
set foldcolumn=0
map <Leader>ddd :bufdo bdelete<CR>
set isfname+=@-@ " for angular
set suffixesadd=.java,.ts,.py,.js,.d.ts
" call g:NERDTreePathNotifier.AddListener("init", "Test")
map <A-Left> :tabprevious<CR>
map <A-Right> :tabnext<CR>
set laststatus=2 " always show status
set guitablabel=%t
set t_Co=256 " This is may or may not needed.
" set background=dark
" colorscheme onedark
set makeprg="gradle test"
let g:UltiSnipsSnippetsDir="~/vimfiles/UltiSnips"
set clipboard^=unnamed
if has('gui_running')
set guifont=source\ code\ pro:h8
endif
let g:jsx_ext_required = 0
set lines=200
set columns=200
" open nerdtree automatically
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree smart | endif
let s:NpmRegistry = {}
function! AddNodeModulesToPath()
let d = getcwd()
if !has_key(s:NpmRegistry, d)
let npmFolder = d.'/node_modules'
if isdirectory(npmFolder)
let s:NpmRegistry[d] = v:true
let &path = &path. ','. npmFolder
else
endif
endif
endfunction
au BufRead *.js,*.ts :call AddNodeModulesToPath()
" don't jump to first result
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
let g:UltiSnipsUsePythonVersion = 3
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsEditSplit="vertical"
let g:gitgutter_diff_base = 'HEAD'
hi Cursor guibg=red
hi iCursor guibg=green
map <Leader>fm :set foldmethod=manual<CR>
map <Leader>fs :set foldmethod=syntax<CR>
map <Leader>fi :set foldmethod=indent<CR>
" for Gvim, gui options, exclude menu and toolbar
set go=egrLtm
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
nmap [c <Plug>GitGutterPrevHunk
nmap ]c <Plug>GitGutterNextHunk
function! Comment()
python3 << EOF
import vim
import re
def add_space(txt):
RGX = r'[({[]\w'
pair = {
'[': ']',
'{': '}',
'(': ')',
}
while True:
matched = re.search(RGX, txt, flags=re.MULTILINE)
if not matched:
return txt
s, e = matched.span()
bracket = txt[s:s+1]
i = s + 1
count = 1
while i < len(txt) and count > 0:
if txt[i] == pair[bracket]:
count -= 1
elif txt[i] == bracket:
count += 1
i += 1
if count != 0:
return txt
j = i - 2
while j > s and re.match(r'\s', txt[j]):
j -= 1
new_content = bracket + ' ' + txt[s+1:j+1] + ' ' + pair[bracket]
txt = txt[:s] + new_content + txt[i:]
return txt
r = vim.current.range
vim.current.buffer[r.start] = add_space(vim.current.buffer[r.start])
EOF
endfunction
noremap <C-c> :call Comment()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment