首页 \ 问答 \ vim,使用vanilla Vim快速切换文件(无插件)(vim, switching between files rapidly using vanilla Vim (no plugins))

vim,使用vanilla Vim快速切换文件(无插件)(vim, switching between files rapidly using vanilla Vim (no plugins))

我明白,限制自己的香草Vim(不使用插件)限制了编辑器的力量,但是当我经常在不同的机器之间切换时,将环境移动到处都是太麻烦了。 我想留在香草Vim。

阻止我的东西是能够在文件之间快速切换。 我(至少相信)对缓冲区窗口标签以及netrw( VexEx等)有很好的了解。

但在编辑器如Sublime Text中 ,我可以直接键入ctrl - p,并立即在文件中。

我知道我可以下载到shell,但是我不知道是否有任何其他“隐藏”的秘密可以快速地切换Vim中的文件,而不仅仅是文件名。


I understand that limiting myself to vanilla Vim (not using plugins) limits the power of the editor, but as I switch between different machines frequently, it is often too much trouble to move my environment around everywhere. I want to just stay in vanilla Vim.

Something that holds me back is the ability to quickly switch between files. I (believe at least) have a good understanding of buffers, windows, tabs, as well as netrw (Vex, Ex, etc).

But in an editor such as Sublime Text, I can just type ctrl-p and instantly I am at the file.

I know that I can drop down to the shell, but I wonder if there are any other "hidden" secrets to rapidly switching between files in Vim based off more than just the filename.


原文:https://stackoverflow.com/questions/16082991
更新时间:2022-06-07 22:06

最满意答案

“State”是指在整个应用程序中设置的变量/属性/ etc。 这些值在任何给定时间都有可能发生变化。 文档说过滤器不应该依赖于外部“状态”。 过滤器需要知道的任何事情都应该作为参数传入,过滤器应该具有进行过滤和返回结果所需的一切。查看文档中的演示,您将看到在“有状态“过滤器,过滤器具有依赖于其用于进行过滤的服务。 该服务值可能会在$digest循环中更改,因此必须在过滤器上设置$stateful属性,以便Angular将再次运行该过滤器,以确保依赖关系未更改状态,从而改变过滤器的结果。

所以,所有的“国家”都应该在这样的论证中,就像这样:

<p>{{myData | multiplyBy:multiplier}}</p>

使用过滤器:

.filter('multiplyBy', function() {
  function filter(input, multiplier) {
    return input * multiplier;
  }
  return filter;
})

如果数据或参数发生更改,则过滤器将再次运行。

stateful将是这样的(不推荐!):

<p>{{myData | myFilter}}</p>

并且过滤器从外部来源获取需要的信息:

.filter('myFilter', ['someDependency', function(someDependency) {
  function filter(input) {
    // let's just say `someDependency = {multiplier: 3}`
    return input * someDependency.multiplier;
  }
  filter.$stateful = true;
  return filter;
}])

在该示例过滤器中, someDependency.multiplier应该作为参数传递给过滤器(如第一个示例),而不是过滤器的依赖。

要进一步澄清问题:如果你调用了一个这样的函数: foo(20)并得到40的结果,你应该得到相同的结果,如果你重复该过程。 如果你再次打电话给foo(20) ,得到92 ,那会很混乱吗? 假设foo不是一个返回随机值的函数,那么每次返回不同数字的唯一方法就是基于隐藏状态(内部改变,而不是作为参数传递)执行不同的方式。 每次给出相同参数的函数返回相同的想法称为“幂等”。

注意: $stateful似乎在Angular 1.3中是新的


"State" is referring to variables/properties/etc that are set throughout the application. These values have the potential to change at any given time. The docs are saying that the filter shouldn't depend on external "state". Anything the filter needs to know about should be passed in as an argument when filtering, and the filter should then have everything it needs to do the filtering and return the result Look over the demo in the docs and you'll see that in the "stateful" filter, the filter has a dependency on a service which it uses to do the filtering. That service value could change during a $digest cycle, so the $stateful property has to be set on the filter so that Angular will run the filter again to be sure that dependency hasn't changed state, this changing the filter's result.

So, all "state" should be in the arguments, like this:

<p>{{myData | multiplyBy:multiplier}}</p>

With a filter like:

.filter('multiplyBy', function() {
  function filter(input, multiplier) {
    return input * multiplier;
  }
  return filter;
})

If the data or arguments change, the filter will run again.

The stateful version would be something like this (not recommended!):

<p>{{myData | myFilter}}</p>

And the filter gets it's needed information from external sources:

.filter('myFilter', ['someDependency', function(someDependency) {
  function filter(input) {
    // let's just say `someDependency = {multiplier: 3}`
    return input * someDependency.multiplier;
  }
  filter.$stateful = true;
  return filter;
}])

In that sample filter, someDependency.multiplier should have been passed in as an argument to the filter (as in the first example), rather than being a dependency of the filter.

To further clarify the problem: If you called a function like this: foo(20) and get a result of 40, you should get the same result if you repeat the process. If you called foo(20) again and got 92, that would be rather confusing, right? Assuming foo isn't a function that is made to return random values, the only way it could return different numbers each time is if it performs differently based on a hidden state (something changing internally, rather than being passed in as an argument). The idea that the function would return the same each time given the same arguments is called being "idempotent".

Note: $stateful seems to be new in Angular 1.3

相关问答

更多