Guest User

Untitled

a guest
Mar 27th, 2015
1,146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 23.61 KB | None | 0 0
  1. "--------------------------------------------------
  2. " NeoBundle Init
  3.  
  4. " Use 256 colors in vim
  5. " some plugins not work without it
  6. set t_Co=256
  7.  
  8. " Turn off filetype plugins before bundles init
  9. filetype off
  10. " Auto installing NeoNeoBundle
  11. let isNpmInstalled = executable("npm")
  12. let iCanHazNeoBundle=1
  13. let neobundle_readme=expand($HOME.'/.vim/bundle/neobundle.vim/README.md')
  14. if !filereadable(neobundle_readme)
  15.     if !isNpmInstalled
  16.         echo "==============================================="
  17.         echo "Your need to install npm to enable all features"
  18.         echo "==============================================="
  19.     endif
  20.     echo "Installing NeoBundle.."
  21.     silent !mkdir -p $HOME/.vim/bundle
  22.     silent !git clone https://github.com/Shougo/neobundle.vim $HOME/.vim/bundle/neobundle.vim
  23.     let iCanHazNeoBundle=0
  24. endif
  25.  
  26. " Call NeoBundle
  27. if has('vim_starting')
  28.     set runtimepath+=$HOME/.vim/bundle/neobundle.vim/
  29. endif
  30.  
  31. call neobundle#begin(expand($HOME.'/.vim/bundle/'))
  32.  
  33. " Determine make or gmake will be used for making additional deps for Bundles
  34. let g:make = 'gmake'
  35. if system('uname -o') =~ '^GNU/'
  36.     let g:make = 'make'
  37. endif
  38.  
  39. "--------------------------------------------------
  40. " Bundles
  41.  
  42. " Let NeoNeoBundle manage NeoNeoBundle
  43. NeoBundle 'Shougo/neobundle.vim'
  44.  
  45. " Instlall vimrpoc. is uses by unite and neocomplcache
  46. " for async searches and calls
  47. NeoBundle 'Shougo/vimproc', {
  48. \ 'build' : {
  49. \     'mac' : 'make -f make_mac.mak',
  50. \     'unix': g:make
  51. \    },
  52. \ }
  53.  
  54. " Some support functions used by delimitmate, and snipmate
  55. NeoBundle 'vim-scripts/tlib'
  56.  
  57. " Improve bookmarks in vim
  58. " Allow word for bookmark marks, and nice quickfix window with bookmark list
  59. " NeoBundle 'AndrewRadev/simple_bookmarks.vim'
  60.  
  61. " plugin for fuzzy file search, most recent files list
  62. " and much more
  63. NeoBundle 'Shougo/unite.vim'
  64.  
  65. " Snippets engine with good integration with neocomplcache
  66. NeoBundle 'Shougo/neosnippet'
  67. " Default snippets for neosnippet, i prefer vim-snippets
  68. "NeoBundle 'Shougo/neosnippet-snippets'
  69. " Default snippets
  70. NeoBundle 'honza/vim-snippets'
  71.  
  72. " Dirr diff
  73. NeoBundle 'vim-scripts/DirDiff.vim'
  74.  
  75. " Colorscheme solarazied for vim
  76. NeoBundle 'altercation/vim-colors-solarized'
  77.  
  78. " Allow autoclose paired characters like [,] or (,),
  79. " and add smart cursor positioning inside it,
  80. NeoBundle 'Raimondi/delimitMate'
  81.  
  82. " Add code static check on write
  83. " need to be properly configured.
  84. " I just enable it, with default config,
  85. " many false positive but still usefull
  86. NeoBundle 'scrooloose/syntastic'
  87. " Install jshint and csslint for syntastic
  88. " Path to jshint if it not installed globally, then use local installation
  89. if !executable("jshint")
  90.     "let g:syntastic_jshint_exec = '~/.vim/node_modules/.bin/jshint'
  91.     let g:syntastic_javascript_jshint_exec = '~/.vim/node_modules/.bin/jshint'
  92.     if isNpmInstalled && !executable(expand(g:syntastic_javascript_jshint_exec))
  93.         silent ! echo 'Installing jshint' && npm --prefix ~/.vim/ install jshint
  94.     endif
  95. endif
  96. " Path to csslint if it not installed globally, then use local installation
  97. if !executable("csslint")
  98.     let g:syntastic_css_csslint_exec='~/.vim/node_modules/.bin/csslint'
  99.     if isNpmInstalled && !executable(expand(g:syntastic_css_csslint_exec))
  100.         silent ! echo 'Installing csslint' && npm --prefix ~/.vim/ install csslint
  101.     endif
  102. endif
  103.  
  104. " Great file system explorer, it appears when you open dir in vim
  105. " Allow modification of dir, and may other things
  106. " Must have
  107. NeoBundle 'scrooloose/nerdtree'
  108.  
  109. " Provide smart autocomplete results for javascript, and some usefull commands
  110. if has("python")
  111.     NeoBundle 'marijnh/tern_for_vim'
  112.     " install node dependencies for tern
  113.     if isNpmInstalled && isdirectory(expand('~/.vim/bundle/tern_for_vim')) && !isdirectory(expand('~/.vim/bundle/tern_for_vim/node_modules'))
  114.         silent ! echo 'Installing tern' && npm --prefix ~/.vim/bundle/tern_for_vim install
  115.     endif
  116. endif
  117.  
  118. " Add smart commands for comments like:
  119. " gcc - Toggle comment for the current line
  120. " gc  - Toggle comments for selected region or number of strings
  121. " Very usefull
  122. NeoBundle 'tomtom/tcomment_vim'
  123.  
  124. " Best git wrapper for vim
  125. " But with my workflow, i really rarely use it
  126. " just Gdiff and Gblame sometimes
  127. NeoBundle 'tpope/vim-fugitive'
  128.  
  129. " Fix-up dot command behavior
  130. " it's kind of service plugin
  131. NeoBundle 'tpope/vim-repeat'
  132.  
  133. " Add usefull hotkey for operation with surroundings
  134. " cs{what}{towhat} - inside '' or [] or something like this allow
  135. " change surroundings symbols to another
  136. " and ds{what} - remove them
  137. NeoBundle 'tpope/vim-surround'
  138.  
  139. " Syntax highlighting for Stylus
  140. NeoBundle 'wavded/vim-stylus'
  141.  
  142. " Add aditional hotkeys
  143. " Looks like i'm not using it at all
  144. "NeoBundle 'tpope/vim-unimpaired'
  145.  
  146. " HTML5 + inline SVG omnicomplete funtion, indent and syntax for Vim.
  147. NeoBundle 'othree/html5.vim'
  148.  
  149. " Syntax highlighting for .jsx (js files for react js)
  150. NeoBundle 'mxw/vim-jsx'
  151.  
  152. " Highlights the matching HTML tag when the cursor
  153. " is positioned on a tag.
  154. NeoBundle 'gregsexton/MatchTag'
  155.  
  156. " Add Support css3 property
  157. NeoBundle 'hail2u/vim-css3-syntax'
  158.  
  159. " Smart indent for javascript
  160. " http://www.vim.org/scripts/script.php?script_id=3081
  161. NeoBundle 'lukaszb/vim-web-indent'
  162.  
  163. " Plugin for changing cursor when entering in insert mode
  164. " looks like it works fine with iTerm Konsole adn xerm
  165. " Applies only on next vim launch after NeoBundleInstall
  166. NeoBundle 'jszakmeister/vim-togglecursor'
  167.  
  168. " Nice statusline/ruler for vim
  169. NeoBundle 'bling/vim-airline'
  170.  
  171. " Improve javascritp syntax higlighting, needed for good folding,
  172. " and good-looking javascritp code
  173. NeoBundle 'jelera/vim-javascript-syntax'
  174.  
  175. "code-completion for jquery, lodash e.t.c
  176. NeoBundle 'othree/javascript-libraries-syntax.vim'
  177.  
  178. " Improved json syntax highlighting
  179. NeoBundle 'elzr/vim-json'
  180.  
  181. " Code complete
  182. NeoBundle 'Shougo/neocomplcache.vim'
  183.  
  184. " Most recent files source for unite
  185. NeoBundle 'Shougo/neomru.vim'
  186.  
  187. " Plugin for chord mappings
  188. NeoBundle 'kana/vim-arpeggio'
  189.  
  190. NeoBundle 'jistr/vim-nerdtree-tabs'
  191.  
  192. NeoBundle 'mattn/emmet-vim'
  193. " JShint :)
  194. " But not necessary with syntastics
  195. " NeoBundle 'walm/jshint.vim'
  196.  
  197. call neobundle#end()
  198.  
  199. " Enable Indent in plugins
  200. filetype plugin indent on
  201. " Enable syntax highlighting
  202. syntax on
  203.  
  204. " If there are uninstalled bundles found on startup,
  205. " this will conveniently prompt you to install them.
  206. NeoBundleCheck
  207.  
  208. "--------------------------------------------------
  209. " Bundles settings
  210.  
  211. "-------------------------
  212. " Unite
  213.  
  214. " Set unite window height
  215. let g:unite_winheight = 10
  216.  
  217. " Start unite in insert mode by default
  218. let g:unite_enable_start_insert = 1
  219.  
  220. " Display unite on the bottom (or bottom right) part of the screen
  221. let g:unite_split_rule = 'botright'
  222.  
  223. " Set short limit for max most recent files count.
  224. " It less unrelative recent files this way
  225. let g:unite_source_file_mru_limit = 100
  226.  
  227. " Enable history for yanks
  228. let g:unite_source_history_yank_enable = 1
  229.  
  230. " Make samll limit for yank history,
  231. let g:unite_source_history_yank_limit = 40
  232.  
  233. " Grep options Default for unite + supress error messages
  234. let g:unite_source_grep_default_opts = '-iRHns'
  235.  
  236. let g:unite_source_rec_max_cache_files = 99999
  237.  
  238. " If ack exists use it instead of grep
  239. if executable('ack-grep')
  240.     " Use ack-grep
  241.     let g:unite_source_grep_command = 'ack-grep'
  242.     " Set up ack options
  243.     let g:unite_source_grep_default_opts = '--no-heading --no-color -a -H'
  244.     let g:unite_source_grep_recursive_opt = ''
  245. endif
  246.  
  247. " Hotkey for open window with most recent files
  248. nnoremap <silent><leader>m :<C-u>Unite file_mru <CR>
  249.  
  250. " Hotkey for open history window
  251. nnoremap <silent><leader>h :Unite -quick-match -max-multi-lines=2 -start-insert -auto-quit history/yank<CR>
  252.  
  253. " Quick tab navigation
  254. nnoremap <silent><leader>' :Unite -quick-match -auto-quit tab<CR>
  255.  
  256. " Fuzzy find files
  257. nnoremap <silent><leader>; :Unite file_rec/async:! -buffer-name=files -start-insert<CR>
  258.  
  259. " Unite-grep
  260. nnoremap <silent><leader>/ :Unite grep:. -no-start-insert -no-quit -keep-focus -wrap<CR>
  261.  
  262.  
  263.  
  264. "-------------------------
  265. " NERDTree
  266.  
  267. " Tell NERDTree to display hidden files on startup
  268. let NERDTreeShowHidden=1
  269.  
  270. " Disable bookmarks label, and hint about '?'
  271. let NERDTreeMinimalUI=1
  272.  
  273. " Display current file in the NERDTree ont the left
  274. nmap <silent> <leader>f :NERDTreeFind<CR>
  275.  
  276. autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
  277.  
  278. " Close all open buffers on entering a window if the only
  279. " buffer that's left is the NERDTree buffer
  280. function! s:CloseIfOnlyNerdTreeLeft()
  281.   if exists("t:NERDTreeBufName")
  282.     if bufwinnr(t:NERDTreeBufName) != -1
  283.       if winnr("$") == 1
  284.         q
  285.       endif
  286.     endif
  287.   endif
  288. endfunction
  289. "-------------------------
  290. " Syntastic
  291.  
  292. " Enable autochecks
  293. let g:syntastic_check_on_open=1
  294. let g:syntastic_enable_signs=1
  295.  
  296. " For correct works of next/previous error navigation
  297. let g:syntastic_always_populate_loc_list = 1
  298.  
  299. " check json files with jshint
  300. let g:syntastic_filetype_map = { "json": "javascript", }
  301.  
  302. " open quicfix window with all error found
  303. nmap <silent> <leader>ll :Errors<cr>
  304. " previous syntastic error
  305. nmap <silent> [ :lprev<cr>
  306. " next syntastic error
  307. nmap <silent> ] :lnext<cr>
  308.  
  309. "-------------------------
  310. " Fugitive
  311.  
  312. " Blame on current line
  313. nmap <silent> <leader>b :.Gblame<cr>
  314. " Blame on all selected lines in visual mode
  315. vmap <silent> <leader>b :Gblame<cr>
  316. " Git status
  317. nmap <silent> <leader>gst :Gstatus<cr>
  318. " like git add
  319. nmap <silent> <leader>gw :Gwrite<cr>
  320. " git diff
  321. nmap <silent> <leader>gd :Gdiff<cr>
  322. " git commit
  323. nmap <silent> <leader>gc :Gcommit<cr>
  324. " git commit all
  325. nmap <silent> <leader>gca :Gcommit -a<cr>
  326. " git fixup previous commit
  327. nmap <silent> <leader>gcf :Gcommit -a --amend<cr>
  328.  
  329.  
  330. "-------------------------
  331. " DelimitMate
  332.  
  333. " Delimitmate place cursor correctly n multiline objects e.g.
  334. " if you press enter in {} cursor still be
  335. " in the middle line instead of the last
  336. let delimitMate_expand_cr = 1
  337.  
  338. " Delimitmate place cursor correctly in singleline pairs e.g.
  339. " if x - cursor if you press space in {x} result will be { x } instead of { x}
  340. let delimitMate_expand_space = 1
  341. let delimitMate_matchpairs = "(:),[:],{:}"
  342. "-------------------------
  343. " Tern_for_vim
  344.  
  345. let tern_show_signature_in_pum = 1
  346.  
  347. " Find all refs for variable under cursor
  348. nmap <silent> <leader>tr :TernRefs<CR>
  349.  
  350. " Smart variable rename
  351. nmap <silent> <leader>tn :TernRename<CR>
  352.  
  353. "-------------------------
  354. " Solarized
  355.  
  356. " if You have problem with background, uncomment this line
  357. " let g:solarized_termtrans=1
  358.  
  359. "-------------------------
  360. " neosnippets
  361. "
  362. " Plugin key-mappings.
  363. imap <C-k>     <Plug>(neosnippet_expand_or_jump)
  364. smap <C-k>     <Plug>(neosnippet_expand_or_jump)
  365. xmap <C-k>     <Plug>(neosnippet_expand_target)
  366.  
  367. " SuperTab like snippets behavior.
  368. imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
  369. \ "\<Plug>(neosnippet_expand_or_jump)"
  370. \: pumvisible() ? "\<C-n>" : "\<TAB>"
  371. smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
  372. \ "\<Plug>(neosnippet_expand_or_jump)"
  373. \: "\<TAB>"
  374.  
  375. " For snippet_complete marker.
  376. if has('conceal')
  377.   set conceallevel=2 concealcursor=i
  378. endif
  379.  
  380. " Enable snipMate compatibility feature.
  381. let g:neosnippet#enable_snipmate_compatibility = 1
  382.  
  383. " Tell Neosnippet about the other snippets
  384. let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
  385.  
  386. " Disables standart snippets. We use vim-snippets bundle instead
  387. let g:neosnippet#disable_runtime_snippets = { '_' : 1 }
  388.  
  389. " Expand snippet and jump to next snippet field on Enter key.
  390. imap <expr><CR> neosnippet#expandable_or_jumpable() ?
  391. \ "\<Plug>(neosnippet_expand_or_jump)" : "\<CR>"
  392.  
  393. "-------------------------
  394. " vim-airline
  395.  
  396. " Colorscheme for airline
  397. let g:airline_theme='understated'
  398.  
  399. " Set custom left separator
  400. let g:airline_left_sep = '▶'
  401.  
  402. " Set custom right separator
  403. let g:airline_right_sep = '◀'
  404.  
  405. " Enable airline for tab-bar
  406. let g:airline#extensions#tabline#enabled = 1
  407.  
  408. " Don't display buffers in tab-bar with single tab
  409. let g:airline#extensions#tabline#show_buffers = 0
  410.  
  411. " Display only filename in tab
  412. let g:airline#extensions#tabline#fnamemod = ':t'
  413.  
  414. " Don't display encoding
  415. let g:airline_section_y = ''
  416.  
  417. " Don't display filetype
  418. let g:airline_section_x = ''
  419.  
  420. "-------------------------
  421. " neocomplcache
  422.  
  423. " Enable NeocomplCache at startup
  424. let g:neocomplcache_enable_at_startup = 1
  425.  
  426. " Max items in code-complete
  427. let g:neocomplcache_max_list = 10
  428.  
  429. " Max width of code-complete window
  430. let g:neocomplcache_max_keyword_width = 80
  431.  
  432. " Code complete is ignoring case until no Uppercase letter is in input
  433. let g:neocomplcache_enable_smart_case = 1
  434.  
  435. " Auto select first item in code-complete
  436. let g:neocomplcache_enable_auto_select = 1
  437.  
  438. " Disable auto popup
  439. let g:neocomplcache_disable_auto_complete = 1
  440.  
  441. " Smart tab Behavior
  442. function! CleverTab()
  443.     " If autocomplete window visible then select next item in there
  444.     if pumvisible()
  445.         return "\<C-n>"
  446.     endif
  447.     " If it's begining of the string then return just tab pressed
  448.     let substr = strpart(getline('.'), 0, col('.') - 1)
  449.     let substr = matchstr(substr, '[^ \t]*$')
  450.     if strlen(substr) == 0
  451.         " nothing to match on empty string
  452.         return "\<Tab>"
  453.     else
  454.         " If not begining of the string, and autocomplete popup is not visible
  455.         " Open this popup
  456.         return "\<C-x>\<C-u>"
  457.     endif
  458. endfunction
  459. inoremap <expr><TAB> CleverTab()
  460.  
  461. " Undo autocomplete
  462. inoremap <expr><C-e> neocomplcache#undo_completion()
  463.  
  464. " Enable omni completion.
  465. autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
  466. autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  467. autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  468.  
  469. " For cursor moving in insert mode
  470. inoremap <expr><Left>  neocomplcache#close_popup() . "\<Left>"
  471. inoremap <expr><Right> neocomplcache#close_popup() . "\<Right>"
  472. inoremap <expr><Up>    neocomplcache#close_popup() . "\<Up>"
  473. inoremap <expr><Down>  neocomplcache#close_popup() . "\<Down>"
  474.  
  475. " disable preview in code complete
  476. set completeopt-=preview
  477.  
  478. "-------------------------
  479. " Arpeggio
  480.  
  481. " map jk to escape
  482. call arpeggio#map('i', '', 0, 'jk', '<ESC>')
  483.  
  484. "--------------------------------------------------
  485. " Colorscheme
  486.  
  487. colorscheme monokai
  488. let g:solarized_termcolors=256
  489.  
  490. let g:molokai_original = 1
  491.  
  492. if &term =~ "xterm-256color" || "screen-256color"
  493.   " 256 colors
  494.   set t_Co=256
  495.   set t_Sf=[3%dm
  496.   set t_Sb=[4%dm
  497. elseif &term =~ "xterm-debian" || &term =~ "xterm-xfree86"
  498.   set t_Co=16
  499.   set t_Sf=[3%dm
  500.   set t_Sb=[4%dm
  501. elseif &term =~ "xterm-color"
  502.   set t_Co=8
  503.   set t_Sf=[3%dm
  504.   set t_Sb=[4%dm
  505. endif
  506.  
  507. syntax on
  508. "--------------------------------------------------
  509. " General options
  510.  
  511. " Enable per-directory .vimrc files and disable unsafe commands in them
  512. "set exrc secure
  513.  
  514. " Set up leader key <leader>, i use default \
  515. "let mapleader = ','
  516.  
  517. " Buffer will be hidden instead of closed when no one display it
  518. "set hidden
  519.  
  520. " Auto reload changed files
  521. set autoread
  522.  
  523. " Always change current dirrectory to current-editing-file dir
  524. "set autochdir
  525.  
  526. " Indicates fast terminal connection
  527. set ttyfast
  528.  
  529. " Set character encoding to use in vim
  530. set encoding=utf-8
  531.  
  532. " Let vim know what encoding we use in our terminal
  533. set termencoding=utf-8
  534.  
  535. " Which EOl used. For us it's unix
  536. " Not works with modifiable=no
  537. if &modifiable
  538.     set fileformat=unix
  539. endif
  540.  
  541. " Enable Tcl interface. Not shure what is exactly mean.
  542. " set infercase
  543.  
  544. " Interprete all files like binary and disable many features.
  545. " set binary
  546.  
  547. "--------------------------------------------------
  548. " Display options
  549.  
  550. " Hide showmode
  551. " Showmode is useless with airline
  552. set noshowmode
  553.  
  554. " Show file name in window title
  555. set title
  556.  
  557. " Mute error bell
  558. set novisualbell
  559.  
  560. " Remove all useless messages like intro screen and use abbreviation like RO
  561. " instead readonly and + instead modified
  562. set shortmess=atI
  563.  
  564. " Enable display whitespace characters
  565. set list
  566.  
  567. " Setting up how to display whitespace characters
  568. set listchars=tab:⇥\ ,trail:·,extends:⋯,precedes:⋯,nbsp:~
  569. highlight SpecialKey guifg=#aaa
  570. " Wrap line only on characters in breakat list like ^I!@*-+;:,./?
  571. " Useless with nowrap
  572. " set linebreak
  573.  
  574. " Numbers of line to scroll when the cursor get off the screen
  575. " Useless with scrolloff
  576. " set scrolljump=5
  577.  
  578. " Numbers of columns to scroll when the cursor get off the screen
  579. " Useless with sidescrollof
  580. " set sidescroll=4
  581.  
  582. " Numbers of rows to keep to the left and to the right off the screen
  583. set scrolloff=10
  584.  
  585. " Numbers of columns to keep to the left and to the right off the screen
  586. set sidescrolloff=10
  587.  
  588. " Vim will move to the previous/next line after reaching first/last char in
  589. " the line with this commnad (you can add 'h' or 'l' here as well)
  590. " <,> stand for arrows in command mode and [,] arrows in visual mode
  591. set whichwrap=b,s,<,>,[,],
  592.  
  593. " Display command which you typing and other command related stuff
  594. set showcmd
  595.  
  596. " Indicate that last window have a statusline too
  597. set laststatus=2
  598.  
  599. " Add a line / column display in the bottom right-hand section of the screen.
  600. " Not needed with airline plugin
  601. "set ruler
  602.  
  603. " Setting up right-hand section(ruller) format
  604. " Not needed with airline plugin
  605. "set rulerformat=%30(%=\:%y%m%r%w\ %l,%c%V\ %P%)
  606.  
  607. " The cursor should stay where you leave it, instead of moving to the first non
  608. " blank of the line
  609. set nostartofline
  610.  
  611. " Disable wrapping long string
  612. set nowrap
  613.  
  614. " Display Line numbers
  615. set number
  616.  
  617. " Highlight line with cursor
  618. set cursorline
  619.  
  620. " maximum text length at 80 symbols, vim automatically breaks longer lines
  621. " set textwidth=80
  622.  
  623. " higlight column right after max textwidth
  624. set colorcolumn=+1
  625.  
  626.  
  627. "--------------------------------------------------
  628. " Tab options
  629.  
  630. " Copy indent from previous line
  631. set autoindent
  632.  
  633. " Enable smart indent. it add additional indents whe necessary
  634. set smartindent
  635.  
  636. " Replace spaces with tabs
  637. set noexpandtab
  638.  
  639. " Whe you hit tab at start of line, indent added according to shiftwidth value
  640. set smarttab
  641.  
  642. " number of spaces to use for each step of indent
  643. set shiftwidth=4
  644.  
  645. " Number of spaces that a Tab in the file counts for
  646. set tabstop=4
  647.  
  648. " Same but for editing operation (not shure what exactly does it means)
  649. " but in most cases tabstop and softtabstop better be the same
  650. set softtabstop=4
  651.  
  652. " Round indent to multiple of 'shiftwidth'.
  653. " Indentation always be multiple of shiftwidth
  654. " Applies to  < and > command
  655. set shiftround
  656.  
  657. "--------------------------------------------------
  658. " Search options
  659.  
  660. " Add the g flag to search/replace by default
  661. set gdefault
  662.  
  663. " Highlight search results
  664. set hlsearch
  665.  
  666. " Ignore case in search patterns
  667. set ignorecase
  668.  
  669. " Override the 'ignorecase' option if the search patter ncontains upper case characters
  670. set smartcase
  671.  
  672. " Live search. While typing a search command, show where the pattern
  673. set incsearch
  674.  
  675. " Disable higlighting search result on Enter key
  676. nnoremap <silent> <cr> :nohlsearch<cr><cr>
  677.  
  678. " Show matching brackets
  679. set showmatch
  680.  
  681. " Make < and > match as well
  682. set matchpairs+=<:>
  683.  
  684.  
  685. "--------------------------------------------------
  686. " Wildmenu
  687.  
  688. " Extended autocmpletion for commands
  689. set wildmenu
  690.  
  691. " Autocmpletion hotkey
  692. set wildcharm=<TAB>
  693.  
  694. "--------------------------------------------------
  695. " Folding
  696.  
  697. " Enable syntax folding in javascript
  698. let javaScript_fold=1
  699.  
  700. " No fold closed at open file
  701. set foldlevelstart=99
  702. set nofoldenable
  703.  
  704. " Keymap to toggle folds with space
  705. nmap <space> za
  706.  
  707. "--------------------------------------------------
  708. " Edit
  709.  
  710. " Allow backspace to remove indents, newlines and old text
  711. set backspace=indent,eol,start
  712.  
  713. " toggle paste mode on \p
  714. set pastetoggle=<leader>p
  715.  
  716. " Add '-' as recognized word symbol. e.g dw delete all 'foo-bar' instead just 'foo'
  717. set iskeyword+=-
  718.  
  719. " Disable backups file
  720. set nobackup
  721.  
  722. " Disable vim common sequense for saving.
  723. " By defalut vim write buffer to a new file, then delete original file
  724. " then rename the new file.
  725. set nowritebackup
  726.  
  727. " Disable swp files
  728. set noswapfile
  729.  
  730. " Do not add eol at the end of file.
  731. set noeol
  732.  
  733. "--------------------------------------------------
  734. " Diff Options
  735.  
  736. " Display filler
  737. set diffopt=filler
  738.  
  739. " Open diff in horizontal buffer
  740. set diffopt+=horizontal
  741.  
  742. " Ignore changes in whitespaces characters
  743. set diffopt+=iwhite
  744.  
  745. "--------------------------------------------------
  746. " Hotkeys
  747.  
  748. " Open new tab
  749. nmap <silent><leader>to :tabnew .<CR>
  750.  
  751. " Replace
  752. nmap <leader>s :%s//<left>
  753. vmap <leader>s :s//<left>
  754.  
  755. " Moving between splits
  756. nmap <leader>w <C-w>w
  757.  
  758. "--------------------------------------------------
  759. " Aautocmd
  760.  
  761. " It executes specific command when specific events occured
  762. " like reading or writing file, or open or close buffer
  763. if has("autocmd")
  764.     " Define group of commands,
  765.     " Commands defined in .vimrc don't bind twice if .vimrc will reload
  766.     augroup vimrc
  767.     " Delete any previosly defined autocommands
  768.     au!
  769.         " Auto reload vim after your cahange it
  770.         au BufWritePost *.vim source $MYVIMRC | AirlineRefresh
  771.         au BufWritePost .vimrc source $MYVIMRC | AirlineRefresh
  772.  
  773.         " Restore cursor position :help last-position-jump
  774.         au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  775.           \| exe "normal g'\"" | endif
  776.  
  777.         " Set filetypes aliases
  778.         au FileType htmldjango set ft=html.htmldjango
  779.         au FileType scss set ft=scss.css
  780.         au FileType less set ft=less.css
  781.         au BufWinEnter * if line2byte(line("$") + 1) > 100000 | syntax clear | endif
  782.         au BufRead,BufNewFile *.js set ft=javascript.javascript-jquery
  783.         au BufRead,BufNewFile *.json set ft=json
  784.         " Execute python \ -mjson.tool for autoformatting *.json
  785.         au BufRead,BufNewFile *.bemhtml set ft=javascript
  786.         au BufRead,BufNewFile *.xjst set ft=javascript
  787.         au BufRead,BufNewFile *.tt2 set ft=tt2
  788.         au BufRead,BufNewFile *.plaintex set ft=plaintex.tex
  789.  
  790.         " Auto close preview window, it uses with tags,
  791.         " I don't use it
  792.         autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
  793.         autocmd InsertLeave * if pumvisible() == 0|pclose|endif
  794.  
  795.         " Disable vertical line at max string length in NERDTree
  796.         autocmd FileType * setlocal colorcolumn=+1
  797.         autocmd FileType nerdtree setlocal colorcolumn=""
  798.  
  799.         " Enable Folding, uses plugin vim-javascript-syntax
  800.         au FileType javascript* call JavaScriptFold()
  801.  
  802.     " Group end
  803.     augroup END
  804.  
  805. endif
  806.  
  807. let g:NERDTreeWinSize=37
  808.  
  809. " open a new file
  810. nnoremap <Leader>o :CtrlP<CR>
  811.  
  812. " save file
  813. nnoremap <Leader>w :w<CR>
  814.  
  815. set runtimepath^=~/.vim/bundle/ctrlp.vim
  816.  
  817. " Copy & paste to system clipboard
  818. vmap <Leader>y "+y
  819. vmap <Leader>d "+d
  820. nmap <Leader>p "+p
  821. nmap <Leader>P "+P
  822. vmap <Leader>p "+p
  823. vmap <Leader>P "+P
  824. nmap <Leader><Leader> V
  825.  
  826. if has('gui_running')
  827.     nnoremap <C-S-tab> :tabprevious<CR>
  828.     nnoremap <C-tab>   :tabnext<CR>
  829.     nnoremap <C-t>     :tabnew<CR>
  830.     inoremap <C-S-tab> <Esc>:tabprevious<CR>i
  831.     inoremap <C-tab>   <Esc>:tabnext<CR>i
  832.     inoremap <C-t>     <Esc>:tabnew<CR>
  833.  
  834.     nnoremap <A-1> 1gt
  835.     nnoremap <A-2> 2gt
  836.     nnoremap <A-3> 3gt
  837.     nnoremap <A-4> 4gt
  838.     nnoremap <A-5> 5gt
  839.     nnoremap <A-6> 6gt
  840.     nnoremap <A-7> 7gt
  841.     nnoremap <A-8> 8gt
  842.     nnoremap <A-9> 9gt
  843.     nnoremap <A-0> 10gt
  844.  
  845.     " inoremap <C-S-w> <Esc>:tabclose<CR>
  846.     " nnoremap <C-S-w> :tabclose<CR>
  847. endif
  848.  
  849. " Automatically jump to end of text you pasted
  850. vnoremap <silent> y y`]
  851. vnoremap <silent> p p`]
  852. nnoremap <silent> p p`]
  853.  
  854. " Hit Enter to go to end of file
  855. nnoremap <CR> G
  856.  
  857. " Hit Backspace to go to beginning of file
  858. nnoremap <BS> gg
  859.  
  860. set colorcolumn=80
Advertisement
Add Comment
Please, Sign In to add comment