Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.80 KB | None | 0 0
  1. "{ Plugins
  2. set nocompatible " be iMproved, required
  3. filetype off " required (for Vundle)
  4.  
  5. " Set the runtime path to include Vundle and inititalize
  6. set rtp+=$HOME/.vim/bundle/Vundle.vim
  7. call vundle#begin('$HOME/.vim/bundle')
  8.  
  9. " let Vundle manage Vundle, required
  10. Plugin 'gmarik/Vundle.vim'
  11.  
  12. " Git integration
  13. Plugin 'tpope/vim-fugitive'
  14.  
  15. " Lean & mean status/tabline for vim that's light as air
  16. Plugin 'bling/vim-airline'
  17.  
  18. " Toggle line numbering mode on focus and insert mode
  19. Plugin 'jeffkreeftmeijer/vim-numbertoggle'
  20.  
  21. " File explorer
  22. Plugin 'scrooloose/nerdtree'
  23.  
  24. " Git status in nerdtree
  25. Plugin 'Xuyuanp/nerdtree-git-plugin'
  26.  
  27. " Be able to change/add/delete surround characters/tags
  28. Plugin 'tpope/vim-surround'
  29.  
  30. " Quickly navigate
  31. Plugin 'easymotion/vim-easymotion'
  32.  
  33. " Full path fuzzy file, buffer, mru, tag, ... finder for Vim
  34. Plugin 'kien/ctrlp.vim'
  35.  
  36. " Syntax checker
  37. Plugin 'scrooloose/syntastic'
  38.  
  39. " JSHint, javascript linter
  40. Plugin 'Shutnik/jshint2.vim'
  41.  
  42. " Syntax highlighting for jade.
  43. Plugin 'digitaltoad/vim-jade'
  44.  
  45. Plugin 'flazz/vim-colorschemes'
  46.  
  47. Plugin 'Valloric/YouCompleteMe'
  48.  
  49. " All plugins must be added before the following line
  50. call vundle#end()
  51. "}
  52.  
  53. " { Working with files
  54. " Allow filetype plugins
  55. " Enable loading the plugin files for specific file types.
  56. " If filetype detection was not switched on yet, it will be as well.
  57. filetype plugin on
  58. " Enable loading the indent file for specific file types.
  59. filetype indent on
  60.  
  61. " Map CtrlP
  62. let g:ctrlp_map = '<c-p>'
  63.  
  64. " When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable
  65. " 'c' - the directory of the current file.
  66. " 'r' - the nearest ancestor that contains one of these directories or files: .git .hg .svn .bzr _darcs
  67. " 'a' - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
  68. " 0 or '' (empty string) - disable this feature.
  69. let g:ctrlp_working_path_mode = 'ra'
  70. let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|ico|git|svn))$'
  71.  
  72. " Exclude files and directories using Vim's wildignore and CtrlP's own g:ctrlp_custom_ignore
  73. set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe
  74.  
  75. " When a file has been detected to have been changed outside of Vim and
  76. " it has not been changed inside of Vim, automatically read it again.
  77. " When the file has been deleted this is not done.
  78. set autoread
  79.  
  80. " When this option is set, the syntax with this name is loaded.
  81. syntax enable
  82.  
  83. " Sets the character encoding used inside Vim. It applies to text in
  84. " the buffers, registers, Strings in expressions, text stored in the
  85. " viminfo file, etc. It sets the kind of characters which Vim can work
  86. " with. See |encoding-names| for the possible values.
  87. set encoding=utf8
  88.  
  89. " Set button to toggle line numbering. The plugin doesn't set the hotkey
  90. " correctly when the user sets NumberToggleTrigger, but will take over
  91. " <C-n> if it isn't set. So I set it to the key I want, then do the same
  92. " mapping it would have done myself. This makes it not eat <C-n> due to
  93. " no user mapping, and gets the mapping correctly.
  94. let g:NumberToggleTrigger = '<C-Right>'
  95. nnoremap <silent> <C-Right> :call NumberToggle()<cr>
  96.  
  97. " Toggle NERDTree
  98. map <c-n> :NERDTreeToggle<CR>
  99.  
  100. "Close vim if the only window left open is NERDTree
  101. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
  102.  
  103. " Use this option to tell the script when (if at all) to change the current
  104. " working directory (CWD) for vim.
  105.  
  106. " If it is set to 0 then the CWD is never changed by the NERD tree.
  107.  
  108. " If set to 1 then the CWD is changed when the NERD tree is first loaded to the
  109. " directory it is initialized in. For example, if you start the NERD tree with >
  110. " :NERDTree /home/marty/foobar
  111. " <
  112. " then the CWD will be changed to /home/marty/foobar and will not be changed
  113. " again unless you init another NERD tree with a similar command.
  114.  
  115. " If the option is set to 2 then it behaves the same as if set to 1 except that
  116. " the CWD is changed whenever the tree root is changed. For example, if the CWD
  117. " is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
  118. " root then the CWD will become /home/marty/foobar/baz.
  119. let g:NERDTreeChDirMode = 2
  120.  
  121. " Make Ctrl-\ switch to the last open file.
  122. map <c-\> :b#<CR>
  123.  
  124. " Faster way to save.
  125. map <leader>w :w<CR>
  126. "}
  127.  
  128. " { Visual
  129. if has("gui_running")
  130. set guioptions-=m " remove menu bar
  131. set guioptions-=T "remove toolbar
  132. set guioptions-=r "remove right-hand scroll bar
  133. set guioptions-=L "remove left-hand scroll bar
  134. endif
  135.  
  136. " When set to "dark", Vim will try to use colors that look good on a
  137. " dark background. When set to "light", Vim will try to use colors that
  138. " look good on a light background. Any other value is illegal.
  139. set background=dark
  140.  
  141. " Load color scheme {name}. This searches 'runtimepath'
  142. " for the file "colors/{name}.vim". The first one that
  143. " is found is loaded.
  144. try
  145. colorscheme desert
  146. catch
  147. endtry
  148.  
  149. " When this option is set, the screen will not be redrawn while
  150. " executing macros, registers and other commands that have not been
  151. " typed. Also, updating the window title is postponed. To force an
  152. " update use |:redraw|.
  153. set lazyredraw
  154.  
  155. " When a bracket is inserted, briefly jump to the matching one. The
  156. " jump is only done if the match can be seen on the screen. The time to
  157. " show the match can be set with 'matchtime'.
  158. " A Beep is given if there is no match (no matter if the match can be
  159. " seen or not). This option is reset when the 'paste' option is set.
  160. " When the 'm' flag is not included in 'cpoptions', typing a character
  161. " will immediately move the cursor back to where it belongs.
  162. set showmatch
  163.  
  164. " Tenths of a second to show the matching paren, when 'showmatch' is
  165. " set. Note that this is not in milliseconds, like other options that
  166. " set a time. This is to be compatible with Nvi.
  167. set matchtime=2
  168.  
  169. " Automatically displays all buffers when there's only one tab open.
  170. let g:airline#extensions#tabline#enabled = 1
  171. "}
  172.  
  173. " { Line numbers and status line
  174. " Show the line number relative to the line with the cursor in front of
  175. " each line. Relative line numbers help you use the |count| you can
  176. " precede some vertical motion commands (e.g. j k + -) with, without
  177. " having to calculate it yourself. Especially useful in combination with
  178. " other commands (e.g. y d c < > gq gw =).
  179. set relativenumber
  180.  
  181. " Print the line number in front of each line.
  182. " If relativenumber enabled, show absolute line number on current line
  183. set number
  184.  
  185. " Always show the status line
  186. " The value of this option influences when the last window will have a
  187. " status line:
  188. " 0: never
  189. " 1: only if there are at least two windows
  190. " 2: always
  191. set laststatus=2
  192.  
  193. " Show the line and column number of the cursor position, separated by a
  194. " comma. When there is room, the relative position of the displayed
  195. " text in the file is shown on the far right:
  196. " Top first line is visible
  197. " Bot last line is visible
  198. " All first and last line are visible
  199. " 45% relative position in the file
  200. set ruler
  201.  
  202. " Format the status line
  203. " set statusline=\%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
  204. set statusline=%t "tail of the filename
  205. set statusline+=%m "modified flag
  206. set statusline+=\ [%{strlen(&fenc)?&fenc:'none'}, "file encoding
  207. set statusline+=%{&ff}] "file format
  208. set statusline+=%h "help file flag
  209. set statusline+=%r "read only flag
  210. set statusline+=%y "filetype
  211. set statusline+=\ \ \ CWD:\ %r%{getcwd()}
  212. set statusline+=%= "left/right separator
  213. set statusline+=%c, "cursor column
  214. set statusline+=%l/%L "cursor line/total lines
  215. set statusline+=\ %P "percent through fileh%m%r%y%=%c,%l/%L\ %P
  216. "}
  217.  
  218. " { Searching
  219. " Override the 'ignorecase' option if the search pattern contains upper
  220. " case characters. Only used when the search pattern is typed and
  221. " 'ignorecase' option is on. Used for the commands "/", "?", "n", "N",
  222. " ":g" and ":s". Not used for "*", "#", "gd", tag search, etc. After
  223. " "*" and "#" you can make 'smartcase' used by doing a "/" command,
  224. " recalling the search pattern from history and hitting <Enter>.
  225. set smartcase
  226.  
  227. " Ignore case in search patterns. Also used when searching in the tags
  228. " file.
  229. set ignorecase
  230.  
  231. " Disable higlighting until the next search.
  232. nnoremap <silent> <space> :noh<CR>
  233.  
  234. " When there is a previous search pattern, highlight all its matches.
  235. " The type of highlighting used can be set with the 'l' occasion in the
  236. " 'highlight' option. This uses the "Search" highlight group by
  237. " default. Note that only the matching text is highlighted, any offsets
  238. " are not applied.
  239. set hlsearch
  240.  
  241. " While typing a search command, show where the pattern, as it was typed
  242. " so far, matches. The matched string is highlighted. If the pattern
  243. " is invalid or not found, nothing is shown. The screen will be updated
  244. " often, this is only useful on fast terminals.
  245. set incsearch
  246.  
  247. " Changes the special characters that can be used in search patterns.
  248. " See |pattern|.
  249. " NOTE: To avoid portability problems with using patterns, always keep
  250. " this option at the default "on". Only switch it off when working with
  251. " old Vi scripts. In any other situation write patterns that work when
  252. " 'magic' is on. Include "\M" when you want to |/\M|.
  253. set magic
  254. "}
  255.  
  256. " { Misc
  257. " Put Vim in Paste mode. This is useful if you want to cut or copy
  258. " some text from one window and paste it in Vim. This will avoid
  259. " unexpected effects.
  260. " Setting this option is useful when using Vim in a terminal, where Vim
  261. " cannot distinguish between typed text and pasted text. In the GUI, Vim
  262. " knows about pasting and will mostly do the right thing without 'paste'
  263. " being set. The same is true for a terminal where Vim handles the
  264. " mouse clicks itself.
  265. set paste
  266.  
  267. " Make vim use the system clipboard by default
  268. set clipboard=unnamed
  269.  
  270. " Move a line of text using ALT+[jk]
  271. nmap <M-j> mz:m+<cr>`z
  272. nmap <M-k> mz:m-2<cr>`z
  273. vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
  274. vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
  275.  
  276. " Number of screen lines to use for the command-line. Helps avoiding
  277. " |hit-enter| prompts.
  278. set cmdheight=2
  279.  
  280. " When off a buffer is unloaded when it is |abandon|ed. When on a
  281. " buffer becomes hidden when it is |abandon|ed. If the buffer is still
  282. " displayed in another window, it does not become hidden, of course.
  283. set hidden
  284.  
  285. " A history of ":" commands, and a history of previous search patterns
  286. " are remembered. This option decides how many entries may be stored in
  287. " each of these histories (see |cmdline-editing|).
  288. set history=500
  289.  
  290. " Close the current buffer
  291. map <leader>bd :Bclose<cr>
  292.  
  293. " Close the current buffer
  294. map <leader>cd :cd %:p:h<cr>:pwd<cr>
  295.  
  296. " Toggle spell checking.
  297. map <leader>ss :setlocal spell!<cr>
  298.  
  299. " Remove the Windows ^M - when the encodings gets messed up
  300. noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
  301.  
  302. " Set startup directory.
  303. cd C:\Dev
  304. "}
  305.  
  306. " { Movement including when deleting
  307. " Minimal number of screen lines to keep above and below the cursor.
  308. " This will make some context visible around where you are working.
  309. set scrolloff=3
  310.  
  311. " Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
  312. " mode. This is a list of items, separated by commas. Each item allows
  313. " a way to backspace over something:
  314. " value effect ~
  315. " indent allow backspacing over autoindent
  316. " eol allow backspacing over line breaks (join lines)
  317. " start allow backspacing over the start of insert; CTRL-W and CTRL-U
  318. " stop once at the start of insert.
  319. " When the value is empty, Vi compatible backspacing is used.
  320. set backspace=indent,eol,start
  321.  
  322. " Allow specified keys that move the cursor left/right to move to the
  323. " previous/next line when the cursor is on the first/last character in
  324. " the line. Concatenate characters to allow this for these keys:
  325. " char key mode ~
  326. " b <BS> Normal and Visual
  327. " s <Space> Normal and Visual
  328. " h "h" Normal and Visual (not recommended)
  329. " l "l" Normal and Visual (not recommended)
  330. " < <Left> Normal and Visual
  331. " > <Right> Normal and Visual
  332. " ~ "~" Normal
  333. " [ <Left> Insert and Replace
  334. " ] <Right> Insert and Replace
  335. set whichwrap=b,s,<,>,h,l
  336.  
  337. " Useful for navigating windows.
  338. map <C-j> <C-W>j
  339. map <C-k> <C-W>k
  340. map <C-h> <C-W>h
  341. map <C-l> <C-W>l
  342. "}
  343.  
  344. " { Tab completion in menus
  345. " Completion mode that is used for the character specified with
  346. " 'wildchar'. It is a comma separated list of up to four parts. Each
  347. " part specifies what to do for each consecutive use of 'wildchar'. The
  348. " first part specifies the behavior for the first use of 'wildchar',
  349. " The second part for the second use, etc.
  350. " These are the possible values for each part:
  351. " "" Complete only the first match.
  352. " "full" Complete the next full match. After the last match,
  353. " the original string is used and then the first match
  354. " again.
  355. " "longest" Complete till longest common string. If this doesn't
  356. " result in a longer string, use the next part.
  357. " "longest:full" Like "longest", but also start 'wildmenu' if it is
  358. " enabled.
  359. " "list" When more than one match, list all matches.
  360. " "list:full" When more than one match, list all matches and
  361. " complete first match.
  362. " "list:longest" When more than one match, list all matches and
  363. " complete till longest common string.
  364. " When there is only a single match, it is fully completed in all cases.
  365. set wildmode=longest,full
  366.  
  367. " When 'wildmenu' is on, command-line completion operates in an enhanced
  368. " mode. On pressing 'wildchar' (usually <Tab>) to invoke completion,
  369. " the possible matches are shown just above the command line, with the
  370. " first match highlighted (overwriting the status line, if there is
  371. " one). Keys that show the previous/next match, such as <Tab> or
  372. " CTRL-P/CTRL-N, cause the highlight to move to the appropriate match.
  373. " When 'wildmode' is used, "wildmenu" mode is used where "full" is
  374. " specified. "longest" and "list" do not start "wildmenu" mode.
  375. set wildmenu
  376. "}
  377.  
  378. " { Language
  379. let $LANG='en'
  380. " Language to use for menu translation.
  381. set langmenu=en
  382. "}
  383.  
  384.  
  385. " { Handle cursor in cygwin [REMOVE ON LINUX]
  386. let &t_ti.="\e[1 q"
  387. let &t_SI.="\e[5 q"
  388. let &t_EI.="\e[1 q"
  389. let &t_te.="\e[0 q"
  390. "}
  391.  
  392. " { Tab settings
  393. " Set tabstop to tell vim how many columns a tab counts for. Linux kernel
  394. " code expects each tab to be eight columns wide. Visual Studio expects
  395. " each tab to be four columns wide. This is the only command here that
  396. " will affect how existing text displays.
  397. set tabstop=4
  398.  
  399. " Set softtabstop to control how many columns vim uses when you hit Tab in
  400. " insert mode. If softtabstop is less than tabstop and expandtab is not
  401. " set, vim will use a combination of tabs and spaces to make up the desired
  402. " spacing. If softtabstop equals tabstop and expandtab is not set, vim
  403. " will always use tabs. When expandtab is set, vim will always use the
  404. " appropriate number of spaces.
  405. set softtabstop=4
  406.  
  407. " Set shiftwidth to control how many columns text is indented with the
  408. " reindent operations (<< and >>) and automatic C-style indentation.
  409. set shiftwidth=4
  410.  
  411. " When expandtab is set, hitting Tab in insert mode will produce the
  412. " appropriate number of spaces.
  413. set expandtab
  414.  
  415. " When on, a <Tab> in front of a line inserts blanks according to
  416. " 'shiftwidth'. 'tabstop' or 'softtabstop' is used in other places. A
  417. " <BS> will delete a 'shiftwidth' worth of space at the start of the
  418. " line.
  419. set smarttab
  420.  
  421. " When on, Vim will change the current working directory whenever you
  422. " open a file, switch buffers, delete a buffer or open/close a window.
  423. " It will change to the directory containing the file which was opened
  424. " or selected.
  425. set autochdir
  426. "}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement