vim-one


Ⅰ. 插件描述

Because Vim's +clientserver is awesome

Ⅱ. 基本信息

创建日期:  2014-02-21
使用用户:  4
Github星:  33
插件作者:  Reed Es

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/reedes/vim-one

Ⅳ. 文档说明

# vim-one

Because Vim’s +clientserver is awesome

click image below to see the animated demo
Image
click image above to see the animated demo

Features

Inspired by Derek Wyatt’s “One Vim ... just one” video, this
rewrite of the mvim script builds on Vim’s +clientserver capability to
better manage remote server sessions.

onevim’s features:

  • Command line launch script to invoke Vim in any of its various startup modes
    (gui, console, etc.)
  • From the command line, load a file into a split or tab
  • Manages single server instance by default, avoiding the inadvertent creation
    of multiple forked gui instances
  • Supports multiple servers through the --servername {name} option
  • Attempting to load a file that is already present in another server instance
    will bring the latter to the foreground

Requirements

Currently requires a recent version of Vim built with +clientserver

Note that this plugin was developed and tested on Mac OS X. See the ‘future
development’ section below for support under Linux and Windows.

Installation

Symlink creation

Create symlinks to the onevim launcher script to invoke Vim with the
capabilities you need. The prefix and suffix of the symlink are
significant:

  • prefix drives Vim’s startup mode (g or m prefix for gui mode, e.g.)
  • suffix drives how a file is opened (s for split, v for vsplit, t for tab)

Choose a string as a filler between the prefix and suffix. In the example
creation of symlinks below, I’m using ‘vim’:

$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/mvime   # gui open with edit (default)
$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/mvims   # gui open in split
$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/mvimv   # gui open in vsplit
$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/mvimt   # gui open in tab(s)
$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/vime    # console open with edit (default)
$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/vims    # console open in split
$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/vimv    # console open in vsplit
$ ln -s ~/.vim/bundle/vim-one/bin/onevim ~/bin/vimt    # console open in tab(s)

The e suffix is merely a placeholder to avoid conflicting with existing commands.

For more details on how Vim uses prefixes to drive its startup mode, see:

:help view

Targeting a specific Vim version

If you have more than one version of Vim installed, you can target the
desired version through the VIM_APP_DIR environment variable.

This will also be necessary if onevim cannot find your Vim directory.

Example of an addition to .bashrc for MacVim users:

export VIM_APP_DIR=/usr/local/Cellar/macvim/7.4-72

Or for the X version of Vim:

export VIM_APP_DIR=/usr/local/Cellar/vim/7.4.161

Note: as mentioned in Issue #2, +clientserver doesn’t appear to be
working as expected in the console version of MacVim. Console users should use
an X-based Vim built with +clientserver to make use of this plugin.

Configuration

Automatic focus switching on swapfile conflicts

If swapfile is enabled and you request that a file be loaded that is
already loaded on another server instance, onevim will automatically
switch to that latter server instance.

In most cases this avoids the annoying ‘E325 ATTENTION’ warning message to
resolve swapfile conflicts.

If you want to retain Vim’s default behavior on swapfile handling, set the
following value to 0 in your .vimrc:

let g:one#handleSwapfileConflicts = 1     " 0=disable, 1=enable (def)

Window placement on splits

To control the placement of windows on splits, add to your .vimrc:

set splitbelow
set splitright

Usage

Invoking via onevim will manage server instance(s) using Vim’s
+clientserver ‘remote’ capability:

  • By default, all files open in a single default session (`--servername
    VIM`)
  • Specify an explicit server name through --servername {name} option to
    target a remote session

The latter feature is for users seeking to manage multiple server
instances of Vim, such as those that are project-specific on the screens
of multiple displays.

There’s no need to specify a --remote option. But if you do, onevim
will pass all of your options through to Vim, no longer managing the
server(s).

See also

If you find onevim useful, check out @reedes’s other Vim plugins:

Future development

If you’ve spotted a problem or have an idea on improving this plugin,
please post to the github project issue page. Or better yet, fork and
offer a pull request. Ports to other platforms (Linux, Windows, etc.) are
welcome.

License

Copyright 2014 by Reed Esau. Because onevim is derived from _mvim_, it
is distributed under the same license terms as Vim itself.

添加新评论