免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 9789 | 回复: 21
打印 上一主题 下一主题

[分享] 超強大的 vim [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-03-07 17:30 |只看该作者 |倒序浏览
大家在 linux 下不知道都用什麼 editor, 今天看到一個佛羅里達中央大學(UCF)學生 Jonathan Warner 的神乎其技 vimrc, 給大家參考.....

移動


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


快速的選擇並改變段落


貼上專用的暫存空間


按照字母排序並且取代.


視窗


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
复制代码

评分

参与人数 1可用积分 +2 收起 理由
crazyhadoop + 2 赞分享

查看全部评分

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
2 [报告]
发表于 2014-03-07 17:39 |只看该作者
如果你只在一台机器上使用, 可以试试.

我可能要在很多台机器上使用 vi, 所以, 基本上, 我只用最基本的功能. 因为我不可能去修改每台机器上的vimrc.

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
3 [报告]
发表于 2014-03-08 10:44 |只看该作者
回复 2# q1208c


    把你的 ~/.vim 拷贝上去能费多少事?

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
4 [报告]
发表于 2014-03-08 10:48 |只看该作者
回复 3# MMMIX

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

自己的机器当然是可以配置的很复杂, 但更多的时候, 我是在别人的机器上, 或者可能根本就没有vim, 只有 vi.
   

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
5 [报告]
发表于 2014-03-08 10:51 |只看该作者
回复 4# q1208c


    很好奇你怎么会经常去使用别人的机器呢?

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
6 [报告]
发表于 2014-03-08 11:09 |只看该作者
回复 5# MMMIX


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

有些人设置的终端是单色的. 黑底绿字. NND, 看得我两眼一片绿. 好在不是天天用, 不然, 我怀疑我以后看什么都是绿色的.

论坛徽章:
0
7 [报告]
发表于 2014-03-08 11:37 |只看该作者
vim早就有啦。的确很强大!

论坛徽章:
0
8 [报告]
发表于 2014-03-08 20:02 |只看该作者
撸主,,,,,,为什么补全这么强大!!   怎么实现的!.....    求教。。。。

论坛徽章:
3
酉鸡
日期:2014-04-23 17:17:56丑牛
日期:2014-05-08 11:41:302015亚冠之德黑兰石油
日期:2015-08-03 11:14:27
9 [报告]
发表于 2014-03-11 13:48 |只看该作者
我自己PC上配置了IVIM,感觉和楼主贴出来的很像,界面很漂亮,功能也很强大
配置方法在这里,有兴趣可以看看
http://blog.csdn.net/jeffreyst_zb/article/details/8909492

论坛徽章:
0
10 [报告]
发表于 2014-03-17 22:04 |只看该作者
很好很强大
先收下了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP