vim-zsh-path-completion


Ⅰ. 插件描述

Zsh-style pathname completion in the Vim command line

Ⅱ. 基本信息

创建日期:  2013-03-23
使用用户:  6
Github星:  25
插件作者:  Jim Stewart

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'fweep/vim-zsh-path-completion'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'fweep/vim-zsh-path-completion'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'fweep/vim-zsh-path-completion'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/fweep/vim-zsh-path-completion

Ⅳ. 文档说明

vim-zsh-path-completion

Provides Zsh-style pathname completion in the Vim command line.

Specifically, it will complete each component of pathname independently
up to the first ambiguous match.

Here's an example:

:edit s/m/a/c/s<C-s>

Will expand to:

:edit src/myproject/app/controllers/something_controller.rb

So long as there are no ambiguous matches along the way. You can
provide as much of each component as you want. This also works:

:edit sr/my/app/c/so<C-s>

If there are any ambiguous matches, it will complete as much as it can.

You can freely intermingle <Tab> and <C-s> completion until you get
the path you want. <C-s> doesn't invoke any completion menus; it just
completes what it can.

Installation

Via pathogen.vim:

cd ~/.vim/bundle
git clone git://github.com/fweep/vim-zsh-path-completion.git

Mappings

To suppress the key mapping:

let g:zsh_path_completion_suppress_mappings = 1

To provide your own mapping, bind to <Plug>ZshPathComplete. The default
is:

cmap <C-s> <Plug>ZshPathComplete

Limitations/Bugs

It doesn't understand context. Whereas Vim builtins like :edit know
that they need a filename argument, and only do <Tab> completion when
appropriate, this will try to expand whatever token is there when you
hit <C-s>.

It doesn't handle quotes/spaces/special characters. That should be fixable.

If a component in the middle of the path is ambiguous, it will discard
everything after the unambiguous prefix (zsh will expand the common
portion and position the cursor at the first differing character,
leaving the rest of the path string intact).

<C-s> only works on the end of the command line; if you move the
cursor to the middle and invoke it, you won't get good results.

I hope to address some of these issues. Soliciting feedback for now.

Please file a [GitHub
issue](https://github.com/fweep/vim-zsh-path-completion/issues) if you find bugs.

A note on clutter

I'm not happy about all the Ruby stuff in the top-level directory. It's
there because Bundler will not allow you to
monitor paths above its root, so I can't use a relative path to
watch() for changes in the plugin directory. Bundler also won't
follow symlinks. If you install the plugin with
pathogen (or another Vim package
handler), it doesn't really matter that the directory is cluttered up.
If you don't use pathogen, well...you should. I'll move everything to a
single test directory once I figure out how to make Bundler happy.

Acknowledgements

This was motivation by a [question on Stack
Overflow](http://stackoverflow.com/questions/15581845/how-to-autocomplete-file-paths-in-vim-just-like-in-zsh)
by Mykle Hansen. Thanks for the idea, Mykle!

License

Copyright (C) 2013 Jim Stewart

MIT License. See LICENSE file.

添加新评论