Vim - 删除直到最后一次出现行中的字符 [英] Vim - Delete til last occurrence of character in line

查看:27
本文介绍了Vim - 删除直到最后一次出现行中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何dtdf 字符串中最后一次出现的字符.

I'm trying to figure out how to dt or df the last occurrence of a character in a string.

例如,假设我有以下行:

For example, let's say I have the following line:

foo not.relevant.text.bar

如果我 f df. 我希望得到 foo related.text.bar 但我想得到 foo bar.使用 f 3df. 不是一个选项,因为我不知道该字符串中有多少个字符.此外,我可能想要获得 foo .bar (f 3dt.),或者如果该行以点结尾,我可能想要获得 foo ..不管有多少,我总是想找到最后一个.

If I f df. I expectedly get foo relevant.text.bar but I would like to get foo bar. Using f 3df. is not an option as I don't know how many of that character will be in the string. Additionally, I may want to get foo .bar (f 3dt.), or if the line ends with a dot, I may want to get foo .. I want to always find the last one regardless of how many there are.

这可能没有正则表达式吗?我想我可以使用正则表达式,但我希望有一个我遗漏的简单 vim 命令.我发现自己经常尝试做这样的事情.

Is this possible without a regex? I suppose I could use a regex but I was hoping there was a simple vim command that I'm missing. I find myself trying to do something like this often.

推荐答案

你可以使用我的 JumpToLastOccurrence 插件.它提供了 ,f/,F/,t/,T 命令,可以做到这一点.

You can use my JumpToLastOccurrence plugin. It provides ,f / ,F / ,t / ,T commands that do just that.

这篇关于Vim - 删除直到最后一次出现行中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆