Chinaunix

标题: 超強大的 vim [打印本页]

作者: wjtvbm    时间: 2014-03-07 17:30
标题: 超強大的 vim
大家在 linux 下不知道都用什麼 editor, 今天看到一個佛羅里達中央大學(UCF)學生 Jonathan Warner 的神乎其技 vimrc, 給大家參考.....

移動
[attach]653384[/attach]

編輯
選擇區快並快速得重新排列.


快速的選擇並改變段落


貼上專用的暫存空間


按照字母排序並且取代.


視窗


Macros
透過 yy, CTRL-A, p, 來遞增陣列


HTML到JSON轉換


差異比較


自動完成 Neocomplete


NERDTree


Git HEAD 和工作中的檔案之間的不同


直接從 vim committing


在 vim 中進行 Git blame


git 歷史紀錄


顯示在 Github 選的行


與其它 plugins 整合的狀態列


監控 Github 上的 issue 並且自動加上 issue number 到 commit message 中


整合 Omnicomplete


即時的 browser


不用 reload 就可以更新 CSS 狀態


在 vim 中執行 JavaScript


好吧, 最後附上跟神一樣的 vimrc
  1. set encoding=utf-8

  2. " Look
  3. set background=dark
  4. colorscheme jellybeans
  5. set guifont=Meslo\ LG\ S\ DZ\ for\ Powerline:h10

  6. " line numbers
  7. set number                        
  8. " relative line numbers
  9. set rnu
  10. " no menus, scrollbars, or other junk
  11. set guioptions=

  12. " make backspace delete characters
  13. set backspace=2

  14. " I like my leader being ','. It's easier to reach
  15. let mapleader = ","

  16. " Disable chimes
  17. set visualbell
  18. set t_vb =
  19. set visualbell t_vb=
  20. au GuiEnter * set visualbell t_vb=

  21. " disable backup and swap files
  22. set nobackup
  23. set noswapfile

  24. " use the OS clipboard
  25. set clipboard=unnamed

  26. " Improve Unix/Windows compatibility
  27. set viewoptions=folds,options,cursor,unix,slash
  28. " allow the cursor to pass the last character
  29. set virtualedit=onemore             " Cursor goes beyond last character
  30. " store more command history
  31. set history=100                                                " Store more history (default is 20)
  32. " store a bunch of undo history
  33. set undolevels=400
  34. " enable spell checking
  35. set spell
  36. " allow buffer switching without saving
  37. set hidden

  38. " Status line
  39. set laststatus=2
  40. " Filename
  41. set statusline=%<%f\
  42. " Options
  43. set statusline+=%w%h%m%r                 
  44. " Git Hotness
  45. set statusline+=%{fugitive#statusline()}
  46. " Filetype
  47. set statusline+=\ [%{&ff}/%Y]
  48. " Directory
  49. set statusline+=\ [%{getcwd()}]
  50. " File info
  51. set statusline+=%=%-14.(%l,%c%V%)\ %p%%

  52. " Show matching brackets/parenthesis
  53. set showmatch
  54. " Don't blink
  55. set matchtime=0
  56. " Find as you type search
  57. set incsearch
  58. " Highlight search terms
  59. set hlsearch
  60. " Windows can be 0 line high
  61. set winminheight=0
  62. " Case insensitive search
  63. set ignorecase
  64. " Case sensitive if we type an uppercase
  65. set smartcase

  66. " CTRL-S
  67. nnoremap <silent> <C-S> :<C-u>Update<CR>
  68. noremap <C-S> :update<CR>
  69. vnoremap <C-S> <C-C>:update<CR>
  70. inoremap <C-S> <C-O>:update<CR>

  71. " Window navigation
  72. map <C-J> <C-W>j
  73. map <C-K> <C-W>k
  74. map <C-L> <C-W>l
  75. map <C-H> <C-W>h

  76. " Use Esc to hide search highlights
  77. nnoremap <Esc> :nohl<CR>

  78. " Wrapped lines goes down/up to next row, rather than next line in file.
  79. nnoremap j gj
  80. nnoremap k gk
  81.         
  82. " Yank from the cursor to the end of the line, to be consistent with C and D.
  83. nnoremap Y y$

  84. " Indent options
  85. set autoindent
  86. set noexpandtab
  87. set tabstop=4
  88. set softtabstop=4
  89. set shiftwidth=4
  90. "set cinkeys=0{,0},:,0#,!^F

  91. " Folding
  92. set foldmethod=syntax
  93. set foldnestmax=10
  94. set nofoldenable
  95. set foldlevel=1

  96. " Pathogen enabled bundle folder
  97. call pathogen#runtime_append_all_bundles()
  98. call pathogen#helptags()

  99. " These must be after pathogen loads
  100. syntax on
  101. filetype on
  102. filetype plugin on
  103. filetype plugin indent on

  104. " Neocomplete
  105. let g:neocomplete#enable_at_startup = 1

  106. " Nodejs dictionary
  107. au FileType javascript set dictionary+=$HOME/vimfiles/bundle/vim-node/dict/node.dict

  108. " Netrw remote transfers
  109. let g:netrw_silent = 1

  110. if has("win32")
  111.         let g:netrw_scp_cmd = "pscp.exe"
  112. endif

  113. " gcc compile C files
  114. autocmd filetype c nnoremap <Leader>c :w <CR>:!gcc % -o %:r && %:r<CR>

  115. " java compile files
  116. autocmd filetype java nnoremap <Leader>c :w <CR>:!javac % && java %:r<CR>

  117. " Fugitive/Git Shortcuts
  118. nnoremap <leader>g :Gstatus<CR>4j
  119. autocmd filetype gitcommit nnoremap <buffer> c :Gcommit<CR>

  120. " Ag, the silver searcher
  121. map <C-\> :execute "Ag " . expand("<cword>") <CR>

  122. " Brolink
  123. let g:bl_autostart = 1
  124. au BufWritePost */static/templates/*.html :BLReloadTemplate

  125. hi CursorLineNr   term=bold ctermfg=Gray gui=bold guifg=#c5c5c5

  126. " GitGutter
  127. let g:gitgutter_realtime = 0
  128. let g:gitgutter_eager = 0

  129. " Neocomplete
  130. let g:neocomplete#enable_smart_case = 1
  131. let g:neocomplete#sources#syntax#min_keyword_length = 2

  132. " <CR>: close popup and save indent.
  133. inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
  134. function! s:my_cr_function()
  135.         return neocomplete#smart_close_popup() . "\<CR>"
  136. endfunction
  137. " <TAB>: completion.
  138. inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
  139. " <C-h>, <BS>: close popup and delete backword char.
  140. inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
  141. inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
  142. inoremap <expr><C-y>  neocomplete#close_popup()
  143. inoremap <expr><C-e>  neocomplete#cancel_popup()

  144. " No scratch
  145. set completeopt-=preview

  146. " Full screen
  147. map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
  148. map <F12> <Esc>:call libcallnr("vimtweak.dll", "SetAlpha", 230)<CR>

  149. " Use powerline fonts on airline
  150. let g:airline_powerline_fonts = 1

  151. " lets start in my www folder
  152. cd ~/www
复制代码

作者: q1208c    时间: 2014-03-07 17:39
如果你只在一台机器上使用, 可以试试.

我可能要在很多台机器上使用 vi, 所以, 基本上, 我只用最基本的功能. 因为我不可能去修改每台机器上的vimrc.
作者: MMMIX    时间: 2014-03-08 10:44
回复 2# q1208c


    把你的 ~/.vim 拷贝上去能费多少事?
作者: q1208c    时间: 2014-03-08 10:48
回复 3# MMMIX

如果根本不是你的机器呢?

自己的机器当然是可以配置的很复杂, 但更多的时候, 我是在别人的机器上, 或者可能根本就没有vim, 只有 vi.
   
作者: MMMIX    时间: 2014-03-08 10:51
回复 4# q1208c


    很好奇你怎么会经常去使用别人的机器呢?
作者: q1208c    时间: 2014-03-08 11:09
回复 5# MMMIX


      我也很好奇, 为啥我总是去别人的机器.

有些人设置的终端是单色的. 黑底绿字. NND, 看得我两眼一片绿. 好在不是天天用, 不然, 我怀疑我以后看什么都是绿色的.
作者: Hugo801122    时间: 2014-03-08 11:37
vim早就有啦。的确很强大!
作者: 流年苍白了记忆    时间: 2014-03-08 20:02
撸主,,,,,,为什么补全这么强大!!   怎么实现的!.....    求教。。。。
作者: jeffreyst    时间: 2014-03-11 13:48
我自己PC上配置了IVIM,感觉和楼主贴出来的很像,界面很漂亮,功能也很强大
配置方法在这里,有兴趣可以看看
http://blog.csdn.net/jeffreyst_zb/article/details/8909492
作者: crakme    时间: 2014-03-17 22:04
很好很强大
先收下了
作者: huang6894    时间: 2014-03-17 22:21
不明觉厉欸!!!
我也想知道怎么自动补全。。。
作者: weichanghe2000    时间: 2014-03-21 22:46
楼主,请教下,补全方面怎么弄的?
要装哪些插件?
我在 http://bbs.chinaunix.net/thread-4132366-1-1.html 求助了一个帖子:
winxp 上 vim 的 omni complete 全能补全 <C-X><C-O> 问题?
可以帮忙看看吗?
谢谢啦。
作者: 十舍七匹狼    时间: 2014-03-26 14:44
我在centos6.4下,把配置代码直接贴进了用户工作目录下的.vimrc中,挂了~
作者: 我只想混口饭吃    时间: 2014-04-10 16:24
vimrc 和 vim 有什么区别?
要去那边下载呢?
作者: zongg    时间: 2014-04-14 15:48
好强大,好多都没见过,都不会用。
作者: qidunhu    时间: 2014-04-16 16:04
尼玛,给跪了~~~
作者: mymtom_cu    时间: 2014-04-30 09:23
一直在用VIM的路过!
作者: SoulChains    时间: 2014-04-30 15:36
我是一个老windows程序员,我支持模块分工来达到更高效的工作效率,即使是开发流程上也应该这样。我觉得这些东西完全可以用一个好的IDE来替代,linux上虽然没有windows上的visual studio IDE这么强大的工具,但也有过得去的,例如slickedit、eclipse等,自己电脑上开发完全可以装这些工具来达到更好的效率。

除非你是在别人机子上操作,才不能装这些IDE,才会需要vi/vim的功底,通常这种情况也只是少数,一般只有在现场调试时才有可能。
作者: catface    时间: 2014-04-30 23:12
确实很强大的VIM 谢谢分享
开始学习中
作者: wonderfulpjz    时间: 2014-05-08 08:16
好强大啊,MARK下
作者: mymtom_cu    时间: 2014-06-03 16:40
回复 4# q1208c

没有VIM安装一个就行了啊!
   
作者: mymtom_cu    时间: 2014-06-03 16:48
回复 18# SoulChains

我只能说,你确实是一个Windows程序员

   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2