NoPaste

.vimrc

von ren22
Beschreibung:
vimrc von ren22
Snippet erstellt:
10.02.2018 14:30:32
Snippet wird automatisch gelöscht:
Niemals

Dein Code:
  1. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  2. " Maintainer:
  3. "       Amir Salihefendic
  4. "       http://amix.dk - amix@amix.dk
  5. "
  6. " Version:
  7. "       5.0 - 29/05/12 15:43:36
  8. "
  9. " Blog_post:
  10. "       http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github
  11. "
  12. " Awesome_version:
  13. "       Get this config, nice color schemes and lots of plugins!
  14. "
  15. "       Install the awesome version from:
  16. "
  17. "           https://github.com/amix/vimrc
  18. "
  19. " Syntax_highlighted:
  20. "       http://amix.dk/vim/vimrc.html
  21. "
  22. " Raw_version:
  23. "       http://amix.dk/vim/vimrc.txt
  24. "
  25. " Sections:
  26. "    -> General
  27. "    -> VIM user interface
  28. "    -> Colors and Fonts
  29. "    -> Files and backups
  30. "    -> Text, tab and indent related
  31. "    -> Visual mode related
  32. "    -> Moving around, tabs and buffers
  33. "    -> Status line
  34. "    -> Editing mappings
  35. "    -> vimgrep searching and cope displaying
  36. "    -> Spell checking
  37. "    -> Misc
  38. "    -> Helper functions
  39. "
  40. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  41.  
  42.  
  43. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  44. " => General
  45. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  46. " Sets how many lines of history VIM has to remember
  47. set history=700
  48.  
  49. " Enable filetype plugins
  50. filetype plugin on
  51. filetype indent on
  52.  
  53. " Set to auto read when a file is changed from the outside
  54. set autoread
  55.  
  56. " With a map leader it's possible to do extra key combinations
  57. " like <leader>w saves the current file
  58. let mapleader = ","
  59. let g:mapleader = ","
  60.  
  61. " Fast saving
  62. nmap <leader>w :w!<cr>
  63.  
  64. " Send more characters for redraws
  65. set ttyfast
  66.  
  67. " Enable mouse use in all modes
  68. set mouse=a
  69.  
  70. " Set this to the name of your terminal that supports mouse codes.
  71. " Must be one of: xterm, xterm2, netterm, dec, jsbterm, pterm
  72. set ttymouse=xterm2
  73.  
  74. " Font
  75. if has('gui_running')
  76. " set guifont=Source\ Code\ Pro\ for\ Powerline\ Regular\ 10
  77.  set guifont=Hack\ Regular\ 9
  78. " set guifont=Droid\ Sans\ Mono\ Slashed\ for\ Powerline\ Regular\ 9
  79. " set guifont=ProggyCleanTT\ 12
  80. " set guifont=Neep\ 11
  81. " set guifont=Monofur\ for\ Powerline\ 12
  82. "set guifont=Hack\ Regular\ 9
  83. "set guifont=Monospace\ 9
  84. endif
  85.  
  86. "set -font=Hack\ Regular\ 9
  87.  
  88. " copy paste ctrl c / ctrl v
  89. source $VIMRUNTIME/mswin.vim
  90. behave mswin
  91.  
  92. "Use TAB to complete when typing words, else inserts TABs as usual.
  93. "Uses dictionary and source files to find matching words to complete.
  94.  
  95. "See help completion for source,
  96. "Note: usual completion is on <C-n> but more trouble to press all the time.
  97. "Never type the same word twice and maybe learn a new spellings!
  98. "Use the Linux dictionary when spelling is in doubt.
  99. "Window users can copy the file to their machine.
  100. function! Tab_Or_Complete()
  101.   if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
  102.     return "\<C-N>"
  103.   else
  104.     return "\<Tab>"
  105.   endif
  106. endfunction
  107. :inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>
  108. :set dictionary="/usr/dict/words
  109. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  110. " => VIM user interface
  111. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  112. " Set 7 lines to the cursor - when moving vertically using j/k
  113. set so=7
  114.  
  115. " Turn on the WiLd menu
  116. set wildmenu
  117.  
  118. " Ignore compiled files
  119. set wildignore=*.o,*~,*.pyc
  120.  
  121. "Always show current position
  122. set ruler
  123.  
  124. " Height of the command bar
  125. set cmdheight=2
  126.  
  127. " A buffer becomes hidden when it is abandoned
  128. set hid
  129.  
  130. " Configure backspace so it acts as it should act
  131. set backspace=eol,start,indent
  132. set whichwrap+=<,>,h,l
  133.  
  134. " Ignore case when searching
  135. set ignorecase
  136.  
  137. " When searching try to be smart about cases
  138. set smartcase
  139.  
  140. " Highlight search results
  141. set hlsearch
  142.  
  143. " Makes search act like search in modern browsers
  144. set incsearch
  145.  
  146. " Don't redraw while executing macros (good performance config)
  147. set lazyredraw
  148.  
  149. " For regular expressions turn magic on
  150. set magic
  151.  
  152. " Show matching brackets when text indicator is over them
  153. set showmatch
  154. " How many tenths of a second to blink when matching brackets
  155. set mat=2
  156.  
  157. " No annoying sound on errors
  158. set noerrorbells
  159. set novisualbell
  160. set t_vb=
  161. set tm=500
  162.  
  163. " show CursorLine
  164. set cursorline
  165. " autocmd InsertEnter * highlight CursorLine guibg=#5FFFD7 guifg=fg
  166. " autocmd InsertLeave * highlight CursorLine guibg=#875F5F guifg=fg
  167.  
  168. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  169. " => Colors and Fonts
  170. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  171. " Enable syntax highlighting
  172. set number
  173. syntax enable
  174. " colorscheme jay
  175. " colorscheme blues
  176. " colorscheme shiny-white-meine
  177. " colorscheme calmar256-dark
  178. " colorscheme aquamarine
  179. " colorscheme lyla
  180. " colorscheme minimalist
  181. " colorscheme github
  182. colorscheme wikipedia
  183. "set background=dark
  184.  
  185.  
  186. " Set extra options when running in GUI mode
  187. if has("gui_running")
  188.     set guioptions-=T
  189.     set guioptions+=e
  190.     set t_Co=256
  191.     set guitablabel=%M\ %t
  192. endif
  193.  
  194. set t_Co=256
  195.  
  196. " Set utf8 as standard encoding and en_US as the standard language
  197. set encoding=utf8
  198.  
  199. " Use Unix as the standard file type
  200. set ffs=unix,dos,mac
  201.  
  202.  
  203. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  204. " => Files, backups and undo
  205. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  206. " Turn backup off, since most stuff is in SVN, git et.c anyway...
  207. set nobackup
  208. set nowb
  209. set noswapfile
  210.  
  211.  
  212. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  213. " => Text, tab and indent related
  214. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  215. " Use spaces instead of tabs
  216. set expandtab
  217.  
  218. " Be smart when using tabs ;)
  219. set smarttab
  220.  
  221. " 1 tab == 4 spaces
  222. set shiftwidth=4
  223. set tabstop=4
  224.  
  225. " Linebreak on 500 characters
  226. " set lbr
  227. " set tw=500
  228.  
  229. set ai "Auto indent
  230. set si "Smart indent
  231. set nowrap "dont Wrap lines
  232.  
  233.  
  234. """"""""""""""""""""""""""""""
  235. " => Visual mode related
  236. """"""""""""""""""""""""""""""
  237. " Visual mode pressing * or # searches for the current selection
  238. " Super useful! From an idea by Michael Naumann
  239. vnoremap <silent> * :call VisualSelection('f')<CR>
  240. vnoremap <silent> # :call VisualSelection('b')<CR>
  241.  
  242.  
  243. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  244. " => Moving around, tabs, windows and buffers
  245. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  246. " Treat long lines as break lines (useful when moving around in them)
  247. map j gj
  248. map k gk
  249.  
  250. " Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
  251. map <space> /
  252. map <c-space> ?
  253.  
  254. " Disable highlight when <leader><cr> is pressed
  255. map <silent> <leader><cr> :noh<cr>
  256.  
  257. " Smart way to move between windows
  258. map <C-j> <C-W>j
  259. map <C-k> <C-W>k
  260. map <C-h> <C-W>h
  261. map <C-l> <C-W>l
  262.  
  263. " Close the current buffer
  264. map <leader>bd :Bclose<cr>
  265.  
  266. " Close all the buffers
  267. map <leader>ba :1,1000 bd!<cr>
  268.  
  269. " Useful mappings for managing tabs
  270. map <leader>tn :tabnew<cr>
  271. map <leader>to :tabonly<cr>
  272. map <leader>tc :tabclose<cr>
  273. map <leader>tm :tabmove
  274.  
  275. " Opens a new tab with the current buffer's path
  276. " Super useful when editing files in the same directory
  277. map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
  278.  
  279. " Switch CWD to the directory of the open buffer
  280. map <leader>cd :cd %:p:h<cr>:pwd<cr>
  281.  
  282. " Specify the behavior when switching between buffers
  283. try
  284.   set switchbuf=useopen,usetab,newtab
  285.   set stal=2
  286. catch
  287. endtry
  288.  
  289. " Return to last edit position when opening files (You want this!)
  290. autocmd BufReadPost *
  291.      \ if line("'\"") > 0 && line("'\"") <= line("$") |
  292.      \   exe "normal! g`\"" |
  293.      \ endif
  294. " Remember info about open buffers on close
  295. set viminfo^=%
  296.  
  297.  
  298. """"""""""""""""""""""""""""""
  299. " => Status line
  300. """"""""""""""""""""""""""""""
  301. " Always show the status line
  302. set laststatus=2
  303.  
  304. " Format the status line
  305. set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
  306.  
  307.  
  308. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  309. " => Editing mappings
  310. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  311. " Remap VIM 0 to first non-blank character
  312. map 0 ^
  313.  
  314. " Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
  315. nmap <M-j> mz:m+<cr>`z
  316. nmap <M-k> mz:m-2<cr>`z
  317. vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
  318. vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
  319.  
  320. if has("mac") || has("macunix")
  321.   nmap <D-j> <M-j>
  322.   nmap <D-k> <M-k>
  323.   vmap <D-j> <M-j>
  324.   vmap <D-k> <M-k>
  325. endif
  326.  
  327. " Delete trailing white space on save, useful for Python and CoffeeScript ;)
  328. func! DeleteTrailingWS()
  329.   exe "normal mz"
  330.   %s/\s\+$//ge
  331.   exe "normal `z"
  332. endfunc
  333. autocmd BufWrite *.py :call DeleteTrailingWS()
  334. autocmd BufWrite *.coffee :call DeleteTrailingWS()
  335.  
  336.  
  337. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  338. " => vimgrep searching and cope displaying
  339. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  340. " When you press gv you vimgrep after the selected text
  341. vnoremap <silent> gv :call VisualSelection('gv')<CR>
  342.  
  343. " Open vimgrep and put the cursor in the right position
  344. map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
  345.  
  346. " Vimgreps in the current file
  347. map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right>
  348.  
  349. " When you press <leader>r you can search and replace the selected text
  350. vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
  351.  
  352. " Do :help cope if you are unsure what cope is. It's super useful!
  353. "
  354. " When you search with vimgrep, display your results in cope by doing:
  355. "   <leader>cc
  356. "
  357. " To go to the next search result do:
  358. "   <leader>n
  359. "
  360. " To go to the previous search results do:
  361. "   <leader>p
  362. "
  363. map <leader>cc :botright cope<cr>
  364. map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
  365. map <leader>n :cn<cr>
  366. map <leader>p :cp<cr>
  367.  
  368.  
  369. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  370. " => Spell checking
  371. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  372. " Pressing ,ss will toggle and untoggle spell checking
  373. map <leader>ss :setlocal spell!<cr>
  374.  
  375. " Shortcuts using <leader>
  376. map <leader>sn ]s
  377. map <leader>sp [s
  378. map <leader>sa zg
  379. map <leader>s? z=
  380.  
  381.  
  382. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  383. " => Misc
  384. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  385. " Remove the Windows ^M - when the encodings gets messed up
  386. noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
  387.  
  388. " Quickly open a buffer for scripbble
  389. map <leader>q :e ~/buffer<cr>
  390.  
  391. " Toggle paste mode on and off
  392. map <leader>pp :setlocal paste!<cr>
  393.  
  394.  
  395.  
  396. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  397. " => Helper functions
  398. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  399. function! CmdLine(str)
  400.     exe "menu Foo.Bar :" . a:str
  401.     emenu Foo.Bar
  402.     unmenu Foo
  403. endfunction
  404.  
  405. function! VisualSelection(direction) range
  406.     let l:saved_reg = @"
  407.     execute "normal! vgvy"
  408.  
  409.     let l:pattern = escape(@", '\\/.*$^~[]')
  410.     let l:pattern = substitute(l:pattern, "\n$", "", "")
  411.  
  412.     if a:direction == 'b'
  413.         execute "normal ?" . l:pattern . "^M"
  414.     elseif a:direction == 'gv'
  415.         call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
  416.     elseif a:direction == 'replace'
  417.         call CmdLine("%s" . '/'. l:pattern . '/')
  418.     elseif a:direction == 'f'
  419.         execute "normal /" . l:pattern . "^M"
  420.     endif
  421.  
  422.     let @/ = l:pattern
  423.     let @" = l:saved_reg
  424. endfunction
  425.  
  426.  
  427. " Returns true if paste mode is enabled
  428. function! HasPaste()
  429.     if &paste
  430.         return 'PASTE MODE  '
  431.     en
  432.     return ''
  433. endfunction
  434.  
  435. " Don't close window, when deleting a buffer
  436. command! Bclose call <SID>BufcloseCloseIt()
  437. function! <SID>BufcloseCloseIt()
  438.    let l:currentBufNum = bufnr("%")
  439.    let l:alternateBufNum = bufnr("#")
  440.  
  441.    if buflisted(l:alternateBufNum)
  442.      buffer #
  443.    else
  444.      bnext
  445.    endif
  446.  
  447.    if bufnr("%") == l:currentBufNum
  448.      new
  449.    endif
  450.  
  451.    if buflisted(l:currentBufNum)
  452.      execute("bdelete! ".l:currentBufNum)
  453.    endif
  454. endfunction
  455.  
  456. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  457. " => NERDTree
  458. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  459.  
  460. "autocmd StdinReadPre * let s:std_in=1
  461. "autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
  462.  
  463. "autocmd vimenter * NERDTree
  464.  
  465.  
  466. "patogenvim
  467. execute pathogen#infect()
  468.  
  469. "syntastic
  470. "set statusline+=%#warningmsg#
  471. "set statusline+=%{SyntasticStatuslineFlag()}
  472. "set statusline+=%*
  473.  
  474. "let g:syntastic_always_populate_loc_list = 1
  475. "let g:syntastic_auto_loc_list = 1
  476. "let g:syntastic_check_on_open = 1
  477. "let g:syntastic_check_on_wq = 0
  478.  
  479. "highlight SyntasticErrorSign ctermfg=red ctermbg=237
  480. "highlight SyntasticWarningSign ctermfg=yellow ctermbg=237
  481. "highlight SyntasticStyleErrorSign ctermfg=red ctermbg=237
  482. "highlight SyntasticStyleWarningSign ctermfg=yellow ctermbg=237
  483.  
  484. "let g:syntastic_sh_checkers=['sh','shellcheck','checkbashisms']
  485.  
  486. "let g:syntastic_check_on_open=1
  487. "let g:syntastic_check_on_wq=1
  488. "let g:syntastic_aggregate_errors=1
  489. "let g:syntastic_error_symbol='✗'
  490. "let g:syntastic_warning_symbol='⚠'
  491. "let g:syntastic_enable_ballons=has('ballon_eval')
  492. "let g:syntastic_always_populate_loc_list=1
  493. "jumps to the error
  494. "let g:syntastic_auto_jump=0
  495. "let g:syntastic_auto_loc_list=1
  496. "let g:syntastic_loc_list_height=3
  497. "let g:syntastic_ignore_files = ['^/usr/', '*node_modules*', '*vendor*', '*build*', '*LOCAL*', '*BASE', '*REMOTE*']
  498. "let g:syntastic_mode_map = { 'mode': 'active' }
  499. "let g:syntastic_javascript_checkers=['jshint', 'jscs']
  500. "let g:syntastic_json_checkers=['jsonlint', 'jsonval']
  501. "let g:syntastic_ruby_checkers=['rubocop','mri']
  502. "let g:syntastic_perl_checkers=['perl','perlcritic','podchecker']
  503. "let g:syntastic_python_checkers=['pylint','pep8','python']
  504. "let g:syntastic_cpp_checkers=['gcc','cppcheck','cpplint','ycm','clang_tidy','clang_check']
  505. "let g:syntastic_c_checkers=['gcc','make','cppcheck','clang_tidy','clang_check']
  506. "let g:syntastic_haml_checkers=['haml_lint', 'haml']
  507. "let g:syntastic_html_checkers=['jshint']
  508. "let g:syntastic_yaml_checkers=['jsyaml']
  509. "let g:syntastic_sh_checkers=['sh','shellcheck','checkbashisms']
  510. "let g:syntastic_vim_checkers=['vimlint']
  511. "let g:syntastic_enable_perl_checker=1
  512. "let g:syntastic_c_clang_tidy_sort=1
  513. "let g:syntastic_c_clang_check_sort=1
  514. "let g:syntastic_c_remove_include_errors=1
  515. "let g:syntastic_quiet_messages = { "level": "[]", "file": ['*_LOCAL_*', '*_BASE_*', '*_REMOTE_*']  }
  516. "let g:syntastic_stl_format = '[%E{E: %fe #%e}%B{, }%W{W: %fw #%w}]'
  517. "let g:syntastic_java_javac_options = "-g:none -source 8 -Xmaxerrs 5 -Xmaswarns 5"
  518.  
  519. set undolevels=10000
  520. set undoreload=10000
  521.  
  522.  
  523. "compile and run c++ gtk3
  524. ":command Make !set $1 `echo "%" | sed 's/\.cpp//g'` ;gcc -o $1 "%" `pkg-config --cflags --libs gtk+-3.0`; chmod o+x $1; ./$1; rm -f $1;
  525. map <F9> : !set $1 `echo "%" \| sed 's/\.cpp//g'` ;gcc -o $1 "%" `pkg-config --cflags --libs gtk+-3.0`; chmod o+x $1; ./$1; rm -f $1; <CR><CR>

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. Alternativ kannst du den gesamten Eintrag auch als Datei herunterladen.