vim-lost


Ⅰ. 插件描述

Ⅱ. 基本信息

创建日期:  2017-05-13
使用用户:  7
Github星:  22
插件作者:  fREW Schmidt

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# lost.vim

Vim plugin to provide a command to help you orient yourself when editing a large
chunk of code. While we should try to avoid having huge functions or huge
classes or huge blobs of code, they will likely exist forever and I aim to make
working with them less painful.

Example

Imagine you have the following code block, and the cursor is where the | is:

sub foo {
   # 1000 lines of nonsense
   |dwigt();
   # 1000 more lines of nonsense
}

If you run the :Lost command you will see sub foo { at the bottom of your
vim window. Nice!

Here's an asciinema demo

Inspiration

(The following is quoted from [the blog
post](https://blog.afoolishmanifesto.com/posts/file-context-lost-in-a-file/)
where I had the idea for this tool.)

One of the subtle brilliances that git provides is context other than simple
line numbers in diffs. I know that it wasn't the first tool to implement such a
feature (diff -p does the same thing) but it was the first one that I've seen
use it by default. For example, the diff
here
includes the following snippet:

@@ -33,9 +44,9 @@ sub _defaults {
    my ($self, $params) = @_;

    $params->{namespace}           ||= [ get_namespace_parts($self) ]->[0];
-   $params->{left_method}         ||= String::CamelCase::decamelize($params->{left_class});
-   $params->{right_method}        ||= String::CamelCase::decamelize($params->{right_class});
-   $params->{self_method}         ||= String::CamelCase::decamelize($self);
+   $params->{left_method}         ||= $decamelize->($params->{left_class});
+   $params->{right_method}        ||= $decamelize->($params->{right_class});
+   $params->{self_method}         ||= $decamelize->($self);
    $params->{left_method_plural}  ||= $self->_pluralize($params->{left_method});
    $params->{right_method_plural} ||= $self->_pluralize($params->{right_method});
    $params->{self_method_plural}  ||= $self->_pluralize($params->{self_method});

The top of the snippet is the function that the change was made in. The
context is not always perfect, but it's right so often it is astounding. This
is exactly what I wanted, but generalized.

Installation

If you don't have a preferred installation method, I recommend installing
pathogen.vim, and then simply copy and
paste:

cd ~/.vim/bundle
git clone git://github.com/frioux/vim-lost

Once help tags have been generated, you can view the manual with
:help lost.

Self-Promotion

Like lost.vim? Follow the repository on
GitHub. And if you're feeling especially
charitable, follow frioux on
Twitter and GitHub.

License

Copyright (c) Arthur Axel fREW Schmidt. Distributed under the same terms as Vim

  1. See :help license.

添加新评论