https://github.com/spf13/spf13-vim
__ _ _____ _
___ _ __ / _/ |___ / __ __(_)_ __ ___
/ __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \
\__ \ |_) | _| |___) |_____|\ V / | | | | | | |
|___/ .__/|_| |_|____/ \_/ |_|_| |_| |_|
|_|
spf13-vim is a distribution of vim plugins and resourcesfor Vim, Gvim and MacVim.
It is a good starting point for anyone intending to use VIMfor development running equally well on Windows, Linux, *nix and Mac.
The distribution is completely customisable using a ~/.vimrc.local
,~/.vimrc.bundles.local
, and ~/.vimrc.before.local
VimRC files.
Unlike traditional VIM plugin structure, which similar toUNIX throws all files into common directories, making updating or disablingplugins a real mess, spf13-vim 3 uses the Vundle plugin management system tohave a well organized vim directory (Similar to mac's app folders). Vundle alsoensures that the latest versions of your plugins are installed and makes iteasy to keep them up to date.
Great care has been taken to ensure that each plugin playsnicely with others, and optional configuration has been provided for what webelieve is the most efficient use.
Lastly (and perhaps, most importantly) It is completelycross platform. It works well on Windows, Linux and OSX without anymodifications or additional configurations. If you are using MacVim or Gvim additional featuresare enabled. So regardless of your environment just clone and run.
To make all the plugins work, specifically neocomplete, you need vim with lua.
The easiest way to install spf13-vim is to use our automatic installer by simply copying andpasting the following line into a terminal. This will install spf13-vim andbackup your existing vim configuration. If you are upgrading from a priorversion (before 3.0) this is also the recommended installation.
RequiresGit 1.7+ and Vim 7.3+
curl https://j.mp/spf13-vim3 -L > spf13-vim.sh && sh spf13-vim.sh
If you have a bash-compatible shell you can run the scriptdirectly:
sh <(curl https://j.mp/spf13-vim3 -L)
On Windows and *nix Gitand Curl are required. Also, if you haven'tdone so already, you'll need to install Vim. The quickest option toinstall all three dependencies (Git, Curl, Vim and spf13-vim) is via Chocolatey NuGet. After installing Chocolatey, execute the following commands onthe command prompt:
C:\> choco install spf13-vim
Note:The spf13-vim package will install Vim also!
If you want to install msysgit,Curl and spf13-vim individually, followthe directions below.
After the installation of Vim you must add a new directoryto your environment variables path to make it work with the script installationof spf13.
Open Vim and write the following command, it will show theinstalled directory:
:echo $VIMRUNTIME
C:\Program Files (X86)\Vim\vim74
Then you need to add it to your environment variable path.After that try execute vim
within command prompt (press Win-R,type cmd
, press Enter) and you’ll see the default vim page.
After installation try running git --version
within command prompt(press Win-R, type cmd
, press Enter) to make sure all good:
C:\> git --version
git version 1.7.4.msysgit.0
Instructionsblatently copied from vundle readme InstallingCurl on Windows is easy as Curl is bundledwith msysgit! But before it can be usedwith Vundle it's required make curl
run in command prompt.The easiest way is to create curl.cmd
with this content
@rem Do not use "echo off" to not affect any child calls.
@setlocal
@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
@curl.exe %*
And copy it to C:\Program Files\Git\cmd\curl.cmd
,assuming msysgit was installed to c:\ProgramFiles\Git
to verify all good, run:
C:\> curl --version
curl 7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8k zlib/1.2.3
Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: Largefile NTLM SSL SSPI libz
The easiest way is to download and run thespf13-vim-windows-install.cmd file. Remember to run this file in Administrator Modeif you want the symlinks to be created successfully.
The simpliest (and safest) way to update is to simply rerunthe installer. It will completely and non destructively upgrade to the latestversion.
curl https://j.mp/spf13-vim3 -L -o - | sh
Alternatively you can manually perform the following steps.If anything has changed with the structure of the configuration you will needto create the appropriate symlinks.
cd $HOME/to/spf13-vim/
git pull
vim +BundleInstall! +BundleClean +q
I'm always happy to take pull requests from others. A goodnumber of people are already contributors to spf13-vim. Go ahead and fork me.
The .vimrc file is suited to programming. It is extremelywell organized and folds in sections. Each section is labeled and each optionis commented.
It fixes many of the inconveniences of vanilla vimincluding
Create ~/.vimrc.local
and ~/.gvimrc.local
for any local customizations.
For example, to override the default color schemes:
echo colorscheme ir_black >> ~/.vimrc.local
Create a ~/.vimrc.before.local
file to defineany customizations that get loaded before the spf13-vim .vimrc
.
For example, to prevent autocd into a file directory:
echo let g:spf13_no_autochdir = 1 >> ~/.vimrc.before.local
For a list of available spf13-vim specific customizationoptions, look at the ~/.vimrc.before
file.
There is an additional tier of customization available tothose who want to maintain a fork of spf13-vim specialized for a particular group.These users can create .vimrc.fork
and .vimrc.bundles.fork
files in the root of their fork. The load order for the configuration is:
.vimrc.before
- spf13-vim before configuration.vimrc.before.fork
- fork before configuration.vimrc.before.local
- before user configuration.vimrc.bundles
- spf13-vim bundle configuration.vimrc.bundles.fork
- fork bundle configuration.vimrc.bundles.local
- local user bundle configuration.vimrc
- spf13-vim vim configuration.vimrc.fork
- fork vim configuration.vimrc.local
- local user configurationSee .vimrc.bundles
for specifics on whatoptions can be set to override bundle configuration. See .vimrc.before
for specifics on what options can be overridden. Most vim configuration optionsshould be set in your .vimrc.fork
file, bundle configuration needsto be set in your .vimrc.bundles.fork
file.
You can specify the default bundles for your fork using .vimrc.before.fork
file. Here is how to create an example .vimrc.before.fork
file ina fork repo for the default bundles.
echo let g:spf13_bundle_groups=[\'general\', \'programming\', \'misc\', \'youcompleteme\'] >> .vimrc.before.fork
Once you have this file in your repo, only the bundles youspecified will be installed during the first installation of your fork.
You may also want to update your README.markdown
file so that the bootstrap.sh
link points to your repository andyour bootstrap.sh
file to pull down your fork.
For an example of a fork of spf13-vim that providescustomization in this manner see taxilian'sfork.
<Leader>ev
opensa new tab containing the .vimrc configuration files listed above. This makes iteasier to get an overview of your configuration and make customizations.
<Leader>sv
sources the .vimrc file, instantly applying your customizations to thecurrently running vim instance.
These two mappings can themselves be customized by settingthe following in .vimrc.before.local:
let g:spf13_edit_config_mapping='<Leader>ev'
let g:spf13_apply_config_mapping='<Leader>sv'
spf13-vim contains a curated set of popular vim plugins,colors, snippets and syntaxes. Great care has been made to ensure that theseplugins play well together and have optimal configuration.
Create ~/.vimrc.bundles.local
for anyadditional bundles.
To add a new bundle, just add one line for each bundle youwant to install. The line should start with the word "Bundle"followed by a string of either the vim.org project name or thegithubusername/githubprojectname. For example, the github project spf13/vim-colors can be addedwith the following command
echo Bundle \'spf13/vim-colors\' >> ~/.vimrc.bundles.local
Once new plugins are added, they have to be installed.
vim +BundleInstall! +BundleClean +q
Create ~/.vimrc.local
if it doesn't alreadyexist.
Add the UnBundle command to this line. It takes the sameinput as the Bundle line, so simply copy the line you want to disable and add'Un' to the beginning.
For example, disabling the 'AutoClose' and'scrooloose/syntastic' plugins
echo UnBundle \'AutoClose\' >> ~/.vimrc.bundles.local
echo UnBundle \'scrooloose/syntastic\' >> ~/.vimrc.bundles.local
Rememberto run ':BundleClean!' after this to remove the existing directories
Here are a few of the plugins:
If you undo changes and then make a new change, in most editorsthe changes you undid are gone forever, as their undo-history is a simple list.Since version 7.0 vim uses an undo-tree instead. If you make a new change afterundoing changes, a new branch is created in that tree. Combined with persistentundo, this is nearly as flexible and safe as git ;-)
Undotree makes that feature more accessible by creating avisual representation of said undo-tree.
QuickStart Launch using <Leader>u
.
NERDTree is a file explorer plugin that provides"project drawer" functionality to your vim editing. You can learnmore about it with :help NERDTree
.
QuickStart Launch using <Leader>e
.
Customizations:
<C-E>
to toggle NERDTree<leader>e
or <leader>nt
to load NERDTreeFind which opens NERDTree where the current file is located.Ctrlp replaces the Command-T plugin with a 100% vimlplugin. It provides an intuitive and fast mechanism to load files from the filesystem (with regex and fuzzy find), from open buffers, and from recently usedfiles.
QuickStart Launch using <c-p>
.
This plugin is a tool for dealing with pairs of"surroundings." Examples of surroundings include parentheses, quotes,and HTML tags. They are closely related to what Vim refers to as text-objects.Provided are mappings to allow for removing, changing, and adding surroundings.
Details follow on the exact semantics, but first, considerthe following examples. An asterisk (*) is used to denote the cursor position.
Old text Command New text ~
"Hello *world!" ds" Hello world!
[123+4*56]/2 cs]) (123+456)/2
"Look ma, I'm *HTML!" cs"<q> <q>Look ma, I'm HTML!</q>
if *x>3 { ysW( if ( x>3 ) {
my $str = *whee!; vllllS' my $str = 'whee!';
For instance, if the cursor was inside "foobar"
, you could type cs"'
to convert the text to 'foobar'
.
There's a lot more, check it out at :help surround
NERDCommenter allows you to wrangle your code comments,regardless of filetype. View help :NERDCommenter
or checkout mypost on NERDCommenter.
QuickStart Toggle comments using <Leader>c<space>
inVisual or Normal mode.
Neocomplete is an amazing autocomplete plugin withadditional support for snippets. It can complete simulatiously from thedictionary, buffer, omnicomplete and snippets. This is the one true plugin thatbrings Vim autocomplete on par with the best editors.
QuickStart Just start typing, it will autocomplete where possible
Customizations:
<C-k>
for completing snippets using Neosnippet.YouCompleteMe is another amazing completion engine. It isslightly more involved to set up as it contains a binary component that theuser needs to compile before it will work. As a result of this however it isvery fast.
To enable YouCompleteMe add youcompleteme
toyour list of groups by overriding it in your .vimrc.before.local
like so: let g:spf13_bundle_groups=['general', 'programming', 'misc','scala', 'youcompleteme']
This is just an example. Remember to choosethe other groups you want here.
Once you have done this you will need to get Vundle to grabthe latest code from git. You can do this by calling :BundleInstall!
.You should see YouCompleteMe in the list.
You will now have the code in your bundles directory andcan proceed to compile the core. Change to the directory it has been downloadedto. If you have a vanilla install then cd~/.spf13-vim-3/.vim/bundle/YouCompleteMe/
should do the trick. Youshould see a file in this directory called install.sh. There are a few optionsto consider before running the installer:
The plugin is well documented on the site linked above. Besure to give that a read and make sure you understand the options you require.
For java users wanting to use eclim be sure to add letg:EclimCompletionMethod = 'omnifunc'
to your .vimrc.local.
Syntastic is a syntax checking plugin that runs buffersthrough external syntax checkers as they are saved and opened. If syntax errorsare detected, the user is notified and is happy because they didn't have tocompile their code or execute their script to find them.
AutoClose does what you expect. It's simple, if you open abracket, paren, brace, quote, etc, it automatically closes it. It handlescurlys correctly and doesn't get in the way of double curlies for things likejinja and twig.
Fugitive adds pervasive git support to git directories invim. For more information, use :help fugitive
Use :Gstatus
to view git status
and type -
on any file to stage or unstage it. Type p
on a file to enter git add -p
and stage specific hunks in thefile.
Use :Gdiff
on an open file to see what changeshave been made to that file
QuickStart <leader>gs
to bring up git status
Customizations:
<leader>gs
:Gstatus<leader>gd
:Gdiff<leader>gc
:Gcommit<leader>gb
:Gblame<leader>gl
:Glog<leader>gp
:Git push<leader>gw
:GwriteThe most feature complete and up to date PHP Integrationfor Vim with proper support for PHP 5.3+ including latest syntax, functions,better fold support, etc.
PIV provides:
Ack.vim uses ack to search inside the current directory fora pattern. You can learn more about it with :help Ack
QuickStart :Ack
Tabularize lets you align statements on their equal signsand other characters
Customizations:
<Leader>a= :Tabularize /=<CR>
<Leader>a: :Tabularize /:<CR>
<Leader>a:: :Tabularize /:\zs<CR>
<Leader>a, :Tabularize /,<CR>
<Leader>a<Bar> :Tabularize /<Bar><CR>
spf13-vim includes the Tagbar plugin. This plugin requiresexuberant-ctags and will automatically generate tags for your open files. Italso provides a panel to navigate easily via tags
QuickStart CTRL-]
while the cursor is on a keyword (such as afunction name) to jump to its definition.
Customizations: spf13-vim binds <Leader>tt
to toggle the tagbarpanel
Note: For full language support, run brew install ctags
toinstall exuberant-ctags.
Tip: Check out :help ctags
for information about VIM'sbuilt-in ctag support. Tag navigation creates a stack which can traversed via Ctrl-]
(to find the source of a token) and Ctrl-T
(to jump back up onelevel).
EasyMotion provides an interactive way to use motions inVim.
It quickly maps each possible jump destination to a keyallowing very fast and straightforward movement.
QuickStart EasyMotion is triggered using the normal movements, but prefixingthem with <leader><leader>
For example this screen shot demonstrates pressing ,,w
Airline provides a lightweight themable statusline with noexternal dependencies. By default this configuration uses the symbols ‹
and ›
as separators for different statusline sections but can beconfigured to use the same symbols as Powerline. An example firstwithout and then with powerline symbols is shown here:
To enable powerline symbols first install one of the Powerline Fonts or patchyour favorite font using the provided instructions. Configure your terminal,MacVim, or Gvim to use the desired font. Finally add letg:airline_powerline_fonts=1
to your .vimrc.before.local
.
spf13-vim ships with a few additional syntaxes:
EDITOR
to mvim -f
)spf13-vim includes solarized and spf13 vim color pack:
Use :color molokai
to switch to a colorscheme.
Terminal Vim users will benefit from solarizing theirterminal emulators and setting solarized support to 16 colors:
let g:solarized_termcolors=16
color solarized
Terminal emulator colorschemes:
It also contains a very complete set of snippets for use withsnipmate or neocomplete.
Here's some tips if you've never used VIM before:
vimtutor
into a shell to go through a brief interactive tutorial inside VIM.i
<ESC>
:q
to exit vim<Leader>
key, which by default maps to \
. Spf13-vim uses let mapleader = ","
to change this to ,
which is in a consistent and convenient location.https://github.com/hyperic/sigar/blob/master/examples/cpuinfo.c
spf13-vim安装与使用
一、简介
spf13-vim是Vim插件与配置的一个发行版本,包含了一整套精心挑选的Vim插件,采用Vundle进行插件管理,并且可以通过下列文件进行个性化配置
~/.vimrc.local #个性化配置文件~/.vimrc.bundles.local #本地bundle配置文件 ~/.vimrc.before.local #早于spf13-vim加载的个性化配置文件
参考:https://github.com/spf13/spf13-vim#fork-customization
二、安装
下面介绍两种安装方式
方式1:执行如下命令,即可完成安装
curl https://j.mp/spf13-vim3 -L > spf13-vim.sh && sh spf13-vim.sh
方式2:通过文件:bootstrap.sh,步骤如下
1、新建目录与文件,如下:
mkdir spf13-vimcd spf13-vimvim bootstrap.shchmod +x bootstrap.sh./bootstrap.sh
文件:bootstrap.sh,内容如下
#!/usr/bin/env bash# Copyright 2014 Steve Francia## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.############################ SETUP PARAMETERSapp_name='spf13-vim'app_dir="$HOME/.spf13-vim-3"[ -z "$git_uri" ] && git_uri='https://github.com/spf13/spf13-vim.git'git_branch='3.0'debug_mode='0'fork_maintainer='0'[ -z "$VUNDLE_URI" ] && VUNDLE_URI="https://github.com/gmarik/vundle.git"############################ BASIC SETUP TOOLSmsg() { printf '%b/n' "$1" >&2}success() { if [ "$ret" -eq '0' ]; then msg "/e[32m[✔]/e[0m ${1}${2}" fi}error() { msg "/e[31m[✘]/e[0m ${1}${2}" exit 1}debug() { if [ "$debug_mode" -eq '1' ] && [ "$ret" -gt '1' ]; then msg "An error occurred in function /"${FUNCNAME[$i+1]}/" on line ${BASH_LINENO[$i+1]}, we're sorry for that." fi}program_exists() { local ret='0' type $1 >/dev/null 2>&1 || { local ret='1'; } # throw error on non-zero return value if [ ! "$ret" -eq '0' ]; then error "$2" fi}variable_set() { if [ -z "$1" ]; then error "You must have your HOME environmental variable set to continue." fi}############################ SETUP FUNCTIONSlnif() { if [ -e "$1" ]; then ln -sf "$1" "$2" fi ret="$?" debug}do_backup() { if [ -e "$2" ] || [ -e "$3" ] || [ -e "$4" ]; then today=`date +%Y%m%d_%s` for i in "$2" "$3" "$4"; do [ -e "$i" ] && [ ! -L "$i" ] && mv "$i" "$i.$today"; done ret="$?" success "$1" debug fi}upgrade_repo() { msg "trying to update $1" if [ "$1" = "$app_name" ]; then cd "$app_dir" && git pull origin "$git_branch" fi if [ "$1" = "vundle" ]; then cd "$HOME/.vim/bundle/vundle" && git pull origin master fi ret="$?" success "$2" debug}clone_repo() { program_exists "git" "Sorry, we cannot continue without GIT, please install it first." if [ ! -e "$app_dir" ]; then git clone --recursive -b "$git_branch" "$git_uri" "$app_dir" ret="$?" success "$1" debug else upgrade_repo "$app_name" "Successfully updated $app_name" fi}clone_vundle() { if [ ! -e "$HOME/.vim/bundle/vundle" ]; then git clone $VUNDLE_URI "$HOME/.vim/bundle/vundle" else upgrade_repo "vundle" "Successfully updated vundle" fi ret="$?" success "$1" debug}create_symlinks() { endpath="$app_dir" if [ ! -d "$endpath/.vim/bundle" ]; then mkdir -p "$endpath/.vim/bundle" fi lnif "$endpath/.vimrc" "$HOME/.vimrc" lnif "$endpath/.vimrc.bundles" "$HOME/.vimrc.bundles" lnif "$endpath/.vimrc.before" "$HOME/.vimrc.before" lnif "$endpath/.vim" "$HOME/.vim" # Useful for fork maintainers touch "$HOME/.vimrc.local" if [ -e "$endpath/.vimrc.fork" ]; then ln -sf "$endpath/.vimrc.fork" "$HOME/.vimrc.fork" elif [ "$fork_maintainer" -eq '1' ]; then touch "$HOME/.vimrc.fork" touch "$HOME/.vimrc.bundles.fork" touch "$HOME/.vimrc.before.fork" fi if [ -e "$endpath/.vimrc.bundles.fork" ]; then ln -sf "$endpath/.vimrc.bundles.fork" "$HOME/.vimrc.bundles.fork" fi if [ -e "$endpath/.vimrc.before.fork" ]; then ln -sf "$endpath/.vimrc.before.fork" "$HOME/.vimrc.before.fork" fi ret="$?" success "$1" debug}setup_vundle() { system_shell="$SHELL" export SHELL='/bin/sh' vim / -u "$app_dir/.vimrc.bundles.default" / "+set nomore" / "+BundleInstall!" / "+BundleClean" / "+qall" export SHELL="$system_shell" success "$1" debug}############################ MAIN()variable_set "$HOME"program_exists "vim" "To install $app_name you first need to install Vim."do_backup "Your old vim stuff has a suffix now and looks like .vim.`date +%Y%m%d%S`" / "$HOME/.vim" / "$HOME/.vimrc" / "$HOME/.gvimrc"clone_repo "Successfully cloned $app_name"create_symlinks "Setting up vim symlinks"clone_vundle "Successfully cloned vundle"setup_vundle "Now updating/installing plugins using Vundle"msg "/nThanks for installing $app_name."msg "© `date +%Y` http://vim.spf13.com/"
2、执行如下命令,进行安装
./bootstrap.sh
报错如下
解决办法:重新安装Git-1.8.5,即可
再次执行命令
./bootstrap.sh
报错如下:
解决办法:
cd ~vim .vimrc.bundles.default#内容如下" Default Bundles { " Use before config if available { if filereadable(expand("~/.vimrc.before")) source ~/.vimrc.before endif " } " Use bundles config { if filereadable(expand("~/.vimrc.bundles")) source ~/.vimrc.bundles endif " }" }
3、重新运行,即可完成安装
./bootstrap.sh
三、插件管理
1、配置并安装插件
echo Bundle /'spf13/vim-colors/' >> ~/.vimrc.bundles.local #插件:vim-colors,需首先在文件.vimrc.bundles.local中进行配置vim +BundleInstall! +BundleClean +q #安装
2、卸载插件
echo UnBundle /'AutoClose/' >> ~/.vimrc.local #卸载插件:AutoCloseecho UnBundle /'scrooloose/syntastic/' >> ~/.vimrc.local #卸载插件:scrooloose/syntastic
进入Vim,执行如下命令
:BundleClean #删除原插件目录