标题:[实践不理想]vim管理插件/插件管理器Vundle,vim下模仿sublime的多光标模式vim-multiple-cursors插件(Vundle的介绍及安装),模仿Sublime Text 的ctrl + p功能的ctrlp.vim 这个插件,模仿sublime text 的ctrl + shift + f 在工程中全局查找某字符ZenCoding.vim插件。 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Sat, 23 Dec 2017 18:05:45 +0000 作者:jackxiang 地址:https://jackxiang.com/post/9574/ 内容: vim查看插件:scriptnames :scriptnames 安装插件的主法,且把要安装插件的配置文件和~/.vimrc文件区分开来了,链接如下: https://blog.csdn.net/lu_embedded/article/details/76732965 Vim 自 7.0 开始支持 tab 页了,这就像很多数文本编辑器那样方便在多文件中切换,而不是只能使用 Buffer 暗地里来回切。默认时标签上显示 tab 序号加上当前打开的文件名。 Vim 中关于 Tab 的操作命令如下: vim -p file1 file2 file3.... 在多标签中打开多个文件 :tabe[dit] 或 :tabnew 在当前标签后打开新的标签 :tabn[ext] 或 gt 切换到下一个 tab :tabp[revious] 或 gT 切换到上一个 tab :tabn [N] 切换到第 N 个 tab :tabfir[st] 切换到第 1 个 tab :tabl[ast] 切换到最后一个 tab :tabs 列出所有的 tab :tabc[lose] 关闭当前 tab, :q 命令也能关闭闭掉当前 tab :tabo[nly] 关闭所有其它 tab Vim杂记:Sublime的配色方案,出现在SecureCRT里的Vim一闪一闪的,失败,取消此配色: http://www.cnblogs.com/fsjohnhuang/p/3911611.html 当Vim 打开了很多buffer 和tab 的时候,想要在不同窗口之间跳转,会比较麻烦,刚给SpaceVim 开发了一款简单的插件,就是在左侧列出所有tab: https://github.com/SpaceVim/SpaceVim git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 编辑你当前用户下的.vimrc [xiangdong@localhost ~]$ vim ~/.vimrc 输入Vundle对应的配置 "======================== Vundle 配置 ============================ "安装方法用这个:git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle set nocompatible filetype off set rtp+=~/.vim/bundle/vundle/ "载入特定目录插件 call vundle#rc() ============================================================= cat /home/xiangdong/.vimrc set nocompatible filetype off set rtp+=~/.vim/bundle/vundle/ "载入特定目录插件 call vundle#rc() "======================= 输入要安装的插件 ========================= Bundle 'gmarik/vundle' Bundle 'Lucius' "tag显示列表 "Bundle 'vim-scripts/taglist.vim' "增强的状态栏 Bundle 'bling/vim-airline' "模拟sublime的ctrl-p快捷键,支持模糊搜索打开文件 Bundle 'kien/ctrlp.vim' "配色工具 Bundle 'altercation/vim-colors-solarized' "对ctrlp.vim模糊搜索算法改进的插件 Bundle 'JazzCore/ctrlp-cmatcher' "<([等括号自动补全插件(模拟sublime) Bundle 'vim-scripts/delimitMate.vim' "快速跳转光标的插件 Bundle 'easymotion/vim-easymotion' "进行缩进对齐的插件 Bundle 'vim-easy-align' "minibuff Bundle 'vim-scripts/minibufexplorerpp' "tagbar Bundle 'majutsushi/tagbar' "BerdTree目录 Bundle 'scrooloose/nerdtree' "python语法检查 Bundle 'PyCQA/pyflakes' "python tag compelte Bundle 'vim-scripts/Pydiction' "markdown 语法 Bundle 'plasticboy/vim-markdown' "自动完成输入 Bundle 'SirVer/ultisnips' Bundle 'honza/vim-snippets' "配色 Bundle 'flazz/vim-colorschemes' "自动补全 Bundle 'SuperTab' "行尾空格 Bundle 'dongweiming/vary.vim' "python 自动补全 autocmd FileType python set omnifunc=pythoncomplete#Complete "php 自动补全 autocmd FileType php set omnifunc=phpcomplete#CompletePHP set fencs=utf-8,GB18030,ucs-bom,default,latin1 set number "显示行号 syntax on "语法高亮 syntax enable "语法高亮 set showmatch " 括号匹配 set shiftwidth=4 " operation >> indents 4 columns; << unindents 4 columns set tabstop=4 " a hard TAB displays as 4 columns set expandtab " insert spaces when hitting TABs set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE set shiftround " round indent to multiple of 'shiftwidth' "set autoindent " align the new line indent with the previous line set hlsearch " set height line search " set mouse=a "set mouse on filetype plugin on let g:pydiction_location = '~/.vim/bundle/Pydiction/complete-dict' let g:pydiction_menu_height = 20 在Vim中运行 :BundleInstall 等待安装完成。 :BundleInstall ctrl + j/k # 进行上下选择 ctrl + x # 在当前窗口水平分屏打开文件 ctrl + v # 同上, 垂直分屏 ctrl + t # 在tab中打开 From:https://www.jianshu.com/p/c67e60abaa45 vim中的杀手级插件: vundle: http://zuyunfei.com/2013/04/12/killer-plugin-of-vim-vundle/ 安装插件 打开一个vim, 运行:BundleInstall 或者在命令行运行 vim +BundleInstall +qall 安装完成后插件就能用了 ####其它常用命令: 更新插件:BundleUpdate 清除不再使用的插件:BundleClean, 列出所有插件:BundleList 查找插件:BundleSearch BundleUpdate报错:[Git] Unable to find remote helper for ‘https’ 可能是在安裝 git 時因為缺少 libcurl 套件所導致 但是環境沒有 libcurl 時一樣可以安裝,只是會不能走 HTTPS 通道而已 若要修復這個問題,只需安裝 libcurl 後重新編譯安裝 git 就好: # 系統為Ubuntu/Debain時,執行以下指令 apt-get install -y libcurl4-openssl-dev # 系統為CentOS/RedHat/Fedora時,執行以下指令 yum install -y libcurl-devel.x86_64 From:https://caloskao.org/git-unable-to-find-remote-helper-for-https/ # 回到 git 原始碼目錄重新編譯並安裝 git cd git-2.7.4 ./configure make prefix=/usr/local all make prefix=/usr/local install git --version :BundleUpdate ,出现:Cannot make changes, 'modifiable' is off :set modifiable or :set ma 来自vim 修改时提示 E21: Cannot make changes, 'Modifiable' is off:https://www.jianshu.com/p/2a511ebcdd9a 实践OK如下: vi ./bundle/vundle/autoload/vundle/scripts.vim 166 set modifiable=on 报语法错:后又修改为恢复原来后,又莫名其妙的好了: 164 " make buffer modifiable 165 " to append without errors 166 set modifiable 结论:VIM有其和UI编辑器的局限,也有其灵活,Sublime有其存在价值,想学不一定能学好。多了快捷键还会冲突等得自己思考布局,是有 灵活性,而较为优秀的UI编辑器,早就精心设置好了,你只需要会开就成,所以,我只选择了vim-multiple-cursors,发现其它插件在vim-multiple-cursors的ctrl+n选中单词向前,Ctrl+p后通,Ctrl+x将选中变为不选中再会跳向下一个,选中完成后,可以使用大写i光标之前插入,大写c删除选中批量修改等vim编辑操作进入insert模式,开始修改文本.,好像出现了覆盖。不想深入,先用着,就这样吧: set fileformat=unix set nu set paste set noswapfile syntax on set ts=4 set sw=4 set shiftwidth=4 set expandtab set nocompatible set cursorline set enc=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 highlight WhitespaceEOL ctermbg=red guibg=red match WhitespaceEOL /\s\+$/ nmap mz:m+`z nmap mz:m-2`z vmap :m'>+`mzgv`yo`z vmap :m'<-2`>my` let &titlestring = expand("%:p") if &term == "screen" set t_ts=^[k set t_fs=^[\ endif if &term == "screen" || &term == "xterm" set title endif set tabstop=4 let g:auto_striptrail = "php,python,ruby" let g:auto_striptab = "php,python,ruby,cpp" " autocmd BufReadPost * :call StripTrailingWhite() " autocmd BufReadPost * :call RetabIndents() set nocompatible " be iMproved filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle Bundle 'gmarik/vundle' "my Bundle here: " " original repos on github Bundle 'terryma/vim-multiple-cursors' let g:multi_cursor_use_default_mapping=0 " Default mapping let g:multi_cursor_next_key='' let g:multi_cursor_prev_key='' let g:multi_cursor_skip_key='' let g:multi_cursor_quit_key='' 步骤一二就行,简单常用批量替换插件即可。 通过Vim+少量插件配置一个高效简洁的IDE: https://www.cnblogs.com/javaminer/p/3842689.html 实践,先安装插件管理 再装vim-multiple-cursors这款插件: 一)vim插件管理器:Vundle的介绍及安装: vim中的杀手级插件: http://zuyunfei.com/2013/04/12/killer-plugin-of-vim-vundle/ ##选中后, 可以进行增删替换a/c/x等,相关常用细节参考:http://foocoder.com/2014/04/09/mei-ri-vimcha-jian-vim-multiple-cursors/ ,移动光标到下一个单词的结尾,用命令”e“,里面的ctrl+e在SecureCRT里面并不能到行尾,用箭头键慢慢移动吧。 这个得装: $git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim Initialized empty Git repository in /home/xiangdong/.vim/bundle/Vundle.vim/.git/ remote: Counting objects: 3132, done. Receiving objects: 22% (690/3132), 124.01 KiB | 38 KiB/s vim +BundleInstall + vundle 二)http://www.wklken.me/posts/2015/06/07/vim-plugin-multiplecursors.html PluginInstall vim-multiple-cursors :Plugin 'terryma/vim-multiple-cursors' 这个: :PlugInstall multiple-cursors 从Github进行安装: Plugin 'terryma/vim-multiple-cursors' vim +BundleInstall + vim-multiple-cursors vim +BundleInstall + ctrlp-funky #https://www.cnblogs.com/javaminer/p/3842689.html vim +BundleInstall + taglist.vim vim +BundleInstall + nerdtree 链接:http://zuyunfei.com/2013/04/12/killer-plugin-of-vim-vundle/ 三)Bundle 'ctrlpvim/ctrlp.vim' #这个不是?? Bundle 'kien/ctrlp.vim' github:https://github.com/kien/ctrlp.vim这是一个超赞的插件,如果使用过sublime-text2,那么肯定很熟悉ctrlp。它可以快速的帮助我们找到项目中的文件。 https://www.jianshu.com/p/SRsmZW set fileformat=unix set nu set paste set noswapfile syntax on set ts=4 set sw=4 set shiftwidth=4 set expandtab set nocompatible set cursorline set enc=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 highlight WhitespaceEOL ctermbg=red guibg=red match WhitespaceEOL /\s\+$/ nmap mz:m+`z nmap mz:m-2`z vmap :m'>+`mzgv`yo`z vmap :m'<-2`>my` let &titlestring = expand("%:p") if &term == "screen" set t_ts=^[k set t_fs=^[\ endif if &term == "screen" || &term == "xterm" set title endif set tabstop=4 let g:auto_striptrail = "php,python,ruby" let g:auto_striptab = "php,python,ruby,cpp" " autocmd BufReadPost * :call StripTrailingWhite() " autocmd BufReadPost * :call RetabIndents() set nocompatible " be iMproved filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle Bundle 'gmarik/vundle' "my Bundle here: " " original repos on github Bundle 'terryma/vim-multiple-cursors' Bundle 'kien/ctrlp.vim' Bundle 'tacahiroy/ctrlp-funky' Bundle 'vim-scripts/taglist.vim' Bundle 'scrooloose/nerdtree' " Bundle 'Lokaltog/vim-powerline' ".................................. " vim-scripts repos Bundle 'YankRing.vim' Bundle 'vcscommand.vim' Bundle 'ShowPairs' Bundle 'SudoEdit.vim' Bundle 'EasyGrep' Bundle 'VOoM' Bundle 'VimIM' ".................................. " non github repos " Bundle 'git://git.wincent.com/command-t.git' "...................................... let g:multi_cursor_use_default_mapping=0 " Default mapping let g:multi_cursor_next_key='' let g:multi_cursor_prev_key='' let g:multi_cursor_skip_key='' let g:multi_cursor_quit_key='' let g:ctrlp_map = '' let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_working_path_mode = '0' map :CtrlPFunky let g:ctrlp_extensions = ['funky'] let g:ctrlp_funky_syntax_highlight = 1 ================================================ 一)推荐vim-multiple-cursors这款插件,是模仿sublime的多光标模式,查找规则就是vim默认的单词匹配(就是你按*时查找单词的规则),像这样:大部分时候还是可以用来做rename refactor的。不过正如楼上所说,做项目还是老实用IDE吧 :) From:https://zhuanlan.zhihu.com/p/23262156 ,在命令行模式下用批量替换啊。:%s/item/item /gc 加c是让你一个个确认。 插件地址:https://github.com/terryma/vim-multiple-cursors 二)ctrlp.vim 这个插件是模仿Sublime Text 的ctrl + p功能,在工程中快速定位某个文件。 三) 'ZenCoding.vim'. " 模仿sublime text 的ctrl + shift + f 在工程中全局查找某字符. " 需先安装ack (这个有Shell下的Linux命令Grep,用了插件快捷键没有了) Ctrl-P在其他编辑器里已经是默认的全局搜索键了,vim 也有ctrlp(https://github.com/ctrlpvim/ctrlp.vim)插件,它可以搜索文件路径上的文件名,还有最近文件等各种快捷打开。看起来似乎挺好的,直到fzf.vim(https://vimawesome.com/plugin/fzf-vim)的出现。fzf的搜索速度更快,而且异步,不会在初始化搜索的时候卡死界面响应。 安装好fzf,然后加载 fzf.vim 插件,将ctrl-p 键位映射成 :Files,就可以体验到高速搜索,中间根本不用等界面响应,等关键词输入,结果就出来了。配合 ag 可以屏蔽掉.gitignore 内的文件。 搜索除了文件快速打开,还有全局行内搜索,之前vimgrep 一直是一个比较常用的命令,然而体验不太好,需要指定搜索内容和搜索范围,还要输一些命令,而且略慢。那么ag(https://github.com/ggreer/the_silver_searcher)一定是目前最好的选择。不管其他因素,进到项目主页,一看是 c 写的基本上就已经稳了。实际上它也确实是目前为止最快的行内搜索。使用的话,需要先安装命令行ag(https://github.com/ggreer/the_silver_searcher),然后安装ack.vim(https://vimawesome.com/plugin/ack-vim),注意不要用ag.vim 它已经不被支持了。 不过有个问题,fzf也内置了对 ack 的支持,只是比ack.vim 不如,所以需要重新映射一个 ack.vim 使用的键位,我个人用了 f 意为 find。 Generated by Jackxiang's Bo-blog 2.1.1 Release