vim 配置

mervyn 2018年6月14日22:41:44Tools评论233

目录

初始化目录

mkdir -p ~/.vim/bundle
mkdir -p ~/.vim/colors
mkdir -p ~/.vim/plugin
mkdir -p ~/.vim/doc

安装插件管理器 Vundle

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

如果需要通过 Vundle 管理插件,只需要在 .vimrc 文件配置相应的插件即可。
注意 插件名需要写在 vundle 块中间:文章源自编程技术分享-https://mervyn.life/f798a5d1.html

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'Plugin Name'
call vundle#end()            " required
filetype plugin indent on    " required

目前本人用到的插件如下:文章源自编程技术分享-https://mervyn.life/f798a5d1.html

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'shawncplus/phpcomplete.vim'
Plugin 'mileszs/ack.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'kien/ctrlp.vim'
Plugin 'stephpy/vim-php-cs-fixer'
call vundle#end()            " required
filetype plugin indent on    " required

保存退出后执行 vim +PluginInstall 即可。文章源自编程技术分享-https://mervyn.life/f798a5d1.html

注意
vim-php-cs-fixer 插件依赖 php-cs-fixer , 如果需要自定义格式化的配置, 在 ~/.php_cs.dist 文件中写对应配置即可。文章源自编程技术分享-https://mervyn.life/f798a5d1.html

Vundle 具体用法可见 https://github.com/VundleVim/Vundle.vim
php-cs-fixer 具体用法可见 https://github.com/FriendsOfPHP/PHP-CS-Fixer文章源自编程技术分享-https://mervyn.life/f798a5d1.html

主题配置

找到一个适合自己的主题,这里我采取的是 monokai 这款主题,样式比较接近 sublime文章源自编程技术分享-https://mervyn.life/f798a5d1.html

安装

  • 下载主题 monokai
  • monokai.vim 放入 ~/.vim/colors

启用主题

~/.vimrc 文件中加入如下内容即可文章源自编程技术分享-https://mervyn.life/f798a5d1.html

colorscheme monokai

函数跳转

安装 ctags

wget http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz
tar xvzf ctags-5.8.tar.gz
cd ctags-5.8/
./configure
sudo make && sudo make install

安装 taglist 插件

wget https://nchc.dl.sourceforge.net/project/vim-taglist/vim-taglist/4.6/taglist_46.zip
unzip taglist_46.zip
mv doc/taglist.txt ~/.vim/doc/
mv plugin/taglist.vim ~/.vim/plugin

下边是本人用的 vim 配置文章源自编程技术分享-https://mervyn.life/f798a5d1.html

colorscheme monokai
set nocompatible              " required
filetype on                  " required
set number
set tabstop=4       "设置 tab 制表符所占宽度为 4
set softtabstop=4   "设置按 tab 时缩进的宽度为 4
set shiftwidth=4    "设置自动缩进宽度为 4
set expandtab       "缩进时将 tab 制表符转换为空格
set encoding=utf-8
set cursorline

" set runtimepath^=~/.vim/bundle/ctrlp.vim
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'shawncplus/phpcomplete.vim'
Plugin 'mileszs/ack.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'kien/ctrlp.vim'
Plugin 'stephpy/vim-php-cs-fixer'
call vundle#end()            " required
filetype plugin indent on    " required

"当NERDTree为剩下的唯一窗口时自动关闭
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"设置树的显示图标
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
let NERDTreeShowLineNumbers=1
let NERDTreeShowHidden=1
let NERDTreeAutoCenter=1
let NERDTreeIgnore=['\.pyc','\~$','\.swp']
let g:NERDTreeChDirMode       = 2
let g:ctrlp_working_path_mode = 'ra'
let g:php_cs_fixer_config_file='.php_cs.dist'

let Tlist_Show_One_File=1     "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow=1   "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Ctags_Cmd="/usr/local/bin/ctags"
let Tlist_Inc_Winwidth=0 "配置打开函数列表的时候不改变窗口大小

augroup PHP
    autocmd!

    " Check for PHP syntax errors after saving a file
    autocmd BufWritePost {*.php} echom system("php -l ".expand('%'))
augroup END

function! UpdateCtags()
    let curdir=getcwd()
    while !filereadable("./tags")
        cd ..
        if getcwd() == "/"
            break
        endif
    endwhile
    if filewritable("./tags")
        !ctags -R --fields=+aimlS --languages=php
        TlistUpdate
    endif
    execute ":cd " . curdir
endfunction

map <C-k><C-b> :NERDTreeToggle<CR>
map <C-k><C-j> :NERDTreeCWD<CR>
map <C-o> :TlistToggle<CR>
map <c-h> :Ack<space>
文章源自编程技术分享-https://mervyn.life/f798a5d1.html
weinxin
我的微信公众号
微信扫一扫
mervyn
新入手的Mac需要做的事 Tools

新入手的Mac需要做的事

最近换了一个mac设备,又折腾了一遍各种环境,顺便记录下mac设置需要修改的配置和必要的软件。系统设置系统偏好设置-> 通用 -> 显示滚动条 -> 始终系统偏好设置-> 通用...
使用 markdown 画流程图、时序图 Tools

使用 markdown 画流程图、时序图

在日常工作中,难免会画一些流程图、时序图。之前都是选择使用在线的画图网站,画完然后截图插入到文档。我个人用的比较多的主要是 腾讯文档 。 相较于截图的方式,代码画图都有哪些好处呢? 使用比较轻便。 不...
Git 常用命令速查表 Tools

Git 常用命令速查表

由于之前一直用sourceTree 对Git的项目进行操作,对 Git 的命令行操作不是很熟。最近切换到了 vsocde 结合remote ssh 插件来开发项目(强烈推荐),个人觉得 vscode ...
PHPStorm 更改 PHP 版本号 Tools

PHPStorm 更改 PHP 版本号

PHPStorm 默认的 PHP 版本是 5.4, 当我们用服务器使用的是 PHP7 时,经常会出现语法错误的提示,这个时候需要将 PHPStorm 中的 PHP 版本进行修改才行。操作步骤如下: P...
更新Github中Fork的代码 Tools

更新Github中Fork的代码

但我们在使用Github的时候,看到觉得不错的项目时,通常会进行 star 或者 fork 操作。 fork 时会将对方的代码同步到我们自己的Github仓库中。但是当我们 fork 了别人的代码以后...
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: