Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1522727
  • 博文数量: 226
  • 博客积分: 3997
  • 博客等级: 少校
  • 技术积分: 2369
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-19 17:26
个人简介

Never save something for a special occasion. Every day in your life is a special occasion.

文章分类

全部博文(226)

文章存档

2018年(5)

2017年(11)

2016年(1)

2015年(17)

2014年(14)

2013年(30)

2012年(5)

2011年(52)

2010年(107)

分类: 其他平台

2014-01-13 20:40:34

关于VIM终极配置的介绍

仓库:

摘录

spf13-vim is a distribution of vim plugins and resources for Vim, Gvim and MacVim.

It is a good starting point for anyone intending to use VIM for development running equally well on Windows, Linux, *nix and Mac.
spf13-vim 3 uses the Vundle plugin management system to have a well organized vim directory (Similar to mac's app folders). Vundle also ensures that the latest versions of your plugins are installed and makes it easy to keep them up to date.
Lastly (and perhaps, most importantly) It is completely cross platform. It works well on Windows, Linux and OSX without any modifications or additional configurations. If you are using MacVim or Gvim additional features are enabled. So regardless of your environment just clone and run.

Linux, *nix, Mac OSX Installation:
cd ~
curl -L > spf13-vim.sh && sh spf13-vim.sh

A highly optimized .vimrc config file

The .vimrc file is suited to programming. It is extremely well organized and folds in sections. Each section is labeled and each option is commented.

Customization

Create ~/.vimrc.local and ~/.gvimrc.local for any local customizations.

Create a ~/.vimrc.before.local file to define any customizations that get loaded before the spf13-vim.vimrc.

The load order for the configuration is:

  1. .vimrc.before.local - before user configuration
  2. .vimrc.before.fork - fork before configuration
  3. .vimrc.bundles.local - local user bundle configuration
  4. .vimrc.bundles.fork - fork bundle configuration
  5. .vimrc.bundles - spf13-vim bundle configuration
  6. .vimrc - spf13-vim vim configuration
  7. .vimrc.fork - fork vim configuration
  8. .vimrc.local - local user configuration

Plugins

spf13-vim contains a curated set of popular vim plugins, colors, snippets and syntaxes. Great care has been made to ensure that these plugins play well together and have optimal configuration.

Adding new plugins

Create ~/.vimrc.bundles.local for any additional bundles.

To add a new bundle

    echo Bundle \'spf13/vim-colors\' >> ~/.vimrc.bundles.local

Removing (disabling) an included plugin

Create ~/.vimrc.local if it doesn't already exist.

Add the UnBundle command to this line. It takes the same input 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.local echo UnBundle \'scrooloose/syntastic\' >> ~/.vimrc.local

Remember to run ':BundleClean!' after this to remove the existing directories

Here are a few of the plugins:

Undotree

If you undo changes and then make a new change, in most editors the 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 after undoing changes, a new branch is created in that tree. Combined with persistent undo, this is nearly as flexible and safe as git ;-)

Undotree makes that feature more accessible by creating a visual representation of said undo-tree.

QuickStart Launch using u.

NERDTree

NERDTree is a file explorer plugin that provides "project drawer" functionality to your vim editing. You can learn more about it with :help NERDTree.

QuickStart Launch using e.

Customizations:

  • Use  to toggle NERDTree
  • Use e or nt to load NERDTreeFind which opens NERDTree where the current file is located.
  • Hide clutter ('.pyc', '.git', '.hg', '.svn', '.bzr')
  • Treat NERDTree more like a panel than a split.

ctrlp

Ctrlp replaces the Command-T plugin with a 100% viml plugin. It provides an intuitive and fast mechanism to load files from the file system (with regex and fuzzy find), from open buffers, and from recently used files.

QuickStart Launch using .

Surround

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, consider the 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"      Look ma, I'm HTML!
  if *x>3 {                 ysW(        if ( x>3 ) {
  my $str = *whee!;         vllllS'     my $str = 'whee!'; 

For instance, if the cursor was inside "foo bar", you could type cs"' to convert the text to 'foo bar'.

There's a lot more, check it out at :help surround

NERDCommenter

NERDCommenter allows you to wrangle your code comments, regardless of filetype. Viewhelp :NERDCommenter or checkout my post on NERDCommenter.

QuickStart Toggle comments using c in Visual or Normal mode.

neocomplcache

NeoComplCache is an amazing autocomplete plugin with additional support for snippets. It can complete simulatiously from the dictionary, buffer, omnicomplete and snippets. This is the one true plugin that brings Vim autocomplete on par with the best editors.

QuickStart Just start typing, it will autocomplete where possible

Customizations:

  • Automatically present the autocomplete menu
  • Support tab and enter for autocomplete
  •  for completing snippets.

neocomplcache image

YouCompleteMe

YouCompleteMe is another amazing completion engine. It is slightly more involved to set up as it contains a binary component that the user needs to compile before it will work. As a result of this however it is very fast.

To enable YouCompleteMe add YouCompleteMe to your list of groups by overriding it in your.vimrc.bundles.local like so:let g:spf13_bundle_groups=['general', 'programming', 'misc', 'scala', 'YouCompleteMe'] This is just an example. Remember to choose the other groups you want here.

Once you have done this you will need to get Vundle to grab the 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 and can proceed to compile the core. Change to the directory it has been downloaded to. If you have a vanilla install thencd ~/.spf13-vim-3/.vim/bundle/YouCompleteMe/ should do the trick. You should see a file in this directory called install.sh. There are a few options to consider before running the installer:

  • Do you want clang support (if you don't know what this is then you likely don't need it)?
    • Do you want to link against a local libclang or have the installer download the latest for you?
  • Do you want support for c# via the omnisharp server?

The plugin is well documented on the site linked above. Be sure 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 let g:EclimCompletionMethod = 'omnifunc' to your .vimrc.local.

Syntastic

Syntastic is a syntax checking plugin that runs buffers through external syntax checkers as they are saved and opened. If syntax errors are detected, the user is notified and is happy because they didn't have to compile their code or execute their script to find them.

[AutoClose]

AutoClose does what you expect. It's simple, if you open a bracket, paren, brace, quote, etc, it automatically closes it. It handles curlys correctly and doesn't get in the way of double curlies for things like jinja and twig.

Fugitive

Fugitive adds pervasive git support to git directories in vim. 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 entergit add -p and stage specific hunks in the file.

Use :Gdiff on an open file to see what changes have been made to that file

QuickStart gs to bring up git status

Customizations:

  • gs :Gstatus
  • gd :Gdiff
  • gc :Gcommit
  • gb :Gblame
  • gl :Glog
  • gp :Git push
  • gw :Gwrite
  • :Git ___ will pass anything along to git.

fugitive image

PIV

The most feature complete and up to date PHP Integration for Vim with proper support for PHP 5.3+ including latest syntax, functions, better fold support, etc.

PIV provides:

  • PHP 5.3 support
  • Auto generation of PHP Doc (,pd on (function, variable, class) definition line)
  • Autocomplete of classes, functions, variables, constants and language keywords
  • Better indenting
  • Full PHP documentation manual (hit K on any function for full docs)

php vim itegration image

Ack.vim

Ack.vim uses ack to search inside the current directory for a pattern. You can learn more about it with :help Ack

QuickStart :Ack

Tabularize

Tabularize lets you align statements on their equal signs and other characters

Customizations:

  • a= :Tabularize /=
  • a: :Tabularize /:
  • a:: :Tabularize /:\zs
  • a, :Tabularize /,
  • a :Tabularize /

Tagbar

spf13-vim includes the Tagbar plugin. This plugin requires exuberant-ctags and will automatically generate tags for your open files. It also provides a panel to navigate easily via tags

QuickStart CTRL-] while the cursor is on a keyword (such as a function name) to jump to it's definition.

Customizations: spf13-vim binds tt to toggle the tagbar panel

tagbar image

Note: For full language support, run brew install ctags to install exuberant-ctags.

Tip: Check out :help ctags for information about VIM's built-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 one level).

EasyMotion

EasyMotion provides an interactive way to use motions in Vim.

It quickly maps each possible jump destination to a key allowing very fast and straightforward movement.

QuickStart EasyMotion is triggered using the normal movements, but prefixing them with 

For example this screen shot demonstrates pressing ,,w

easymotion image

Airline

Airline provides a lightweight themable statusline with no external dependencies. By default this configuration uses the symbols ? and ? as separators for different statusline sections but can be configured to use the same symbols as Powerline. An example first without and then with powerline symbols is shown here:

airline image

To enable powerline symbols first install one of the Powerline Fonts or patch your favorite font using the provided instructions. Configure your terminal, MacVim, or Gvim to use the desired font. Finally addlet g:airline_powerline_fonts=1 to your .vimrc.before.local.

Additional Syntaxes

spf13-vim ships with a few additional syntaxes:

  • Markdown (bound to *.markdown, *.md, and *.mk)
  • Twig
  • Git commits (set your EDITOR to mvim -f)

Amazing Colors

spf13-vim includes solarized and spf13 vim color pack:

  • ir_black
  • molokai
  • peaksea

Use :color molokai to switch to a color scheme.

Terminal Vim users will benefit from solarizing their terminal emulators and setting solarized support to 16 colors:

let g:solarized_termcolors=16
color solarized 

Terminal emulator colorschemes:

  •  (iTerm2, Terminal.app)
  •  (KDE Konsole)
  •  (Gnome Terminal)

Snippets

It also contains a very complete set of snippets for use with snipmate or NeoComplCache.



阅读(20564) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~