使用 a.vim 进行 C++

发布于 2024-08-19 18:48:10 字数 164 浏览 1 评论 0原文

有没有办法使用 a.vim 插件在 .h、.cxx .txx 文件之间切换?或者,您能提供另一种解决方案吗?这个想法是自动从 .h -> 切换。 .txx-> .cxx 在按下按键时。

非常感谢你们俩!

is there a way to use the a.vim plugin to switch between .h, .cxx and .txx files? Alternatively, can you provide another solution? The idea is to automagically switch from .h -> .txx -> .cxx at the press of a key.

A Big Thanks to both of you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

也只是曾经 2024-08-26 18:48:10

在 a.vim 中查找包含 AddAlternateExtensionMapping 的行。第一个参数是当前文件的扩展名,第二个参数是您要使用 :A 切换到的文件的扩展名列表。它们按优先顺序列出。就您而言,您必须对其进行设置,以便它能够循环运行。

call <SID>AddAlternateExtensionMapping('h', 'txx,cxx')
call <SID>AddAlternateExtensionMapping('txx', 'cxx,h')
call <SID>AddAlternateExtensionMapping('cxx', 'h,txx')

现在,如果存在,则从 .h 转到 .txx,如果不存在,则从 .cxx 转到。

Look for the lines in a.vim that contain AddAlternateExtensionMapping. The first argument is the extension of the current file, the second is a list of extensions of the file you'd like to switch to with :A. They are listed in order of preference. In your case, you'd have to set it up so that it would go in a cycle.

call <SID>AddAlternateExtensionMapping('h', 'txx,cxx')
call <SID>AddAlternateExtensionMapping('txx', 'cxx,h')
call <SID>AddAlternateExtensionMapping('cxx', 'h,txx')

So now you go from .h to .txx if it exists or .cxx if it doesn't.

揽月 2024-08-26 18:48:10

IIRC,在最新版本的alternate 中,有一个选项可以告诉您要使用的首选扩展。您查看过该插件的文档/第一条注释行吗?

IIRC, with the latest versions of alternate, there is an option that tells the preferred extensions to use. Did you have a look in the doc/first comment lines of the plugin?

薔薇婲 2024-08-26 18:48:10

a.vim 的一个有价值的替代品是 altr

altr< /a> – 无需交互即可切换到丢失的文件


默认情况下,此插件允许您在“备用”Vim 脚本文件、C、C++ 和 Objective-C 文件以及 ASP.NET 文件之间切换,但您也可以轻松添加自己的备用文件。

设置您喜欢的映射

  • 安装后,

    使用 Ex 命令以 a.vim 方式

    <前><代码>命令!调用 altr#forward()

  • 或使用映射

    nmap a (altr-forward)
    nmap A (altr-back)
    

A worthy alternative to a.vim is altr.

altr – Switch to the missing file without interaction

By default this plugin lets you switch between "alternate" Vim script files, C, C++, and Objective-C files, and ASP.NET files, but you can easily add your own alternates too.

After installation, set up the mappings that you prefer,

  • either the a.vim way, using an Ex command

    command! A call altr#forward()
    
  • or using mappings

    nmap <Leader>a <Plug>(altr-forward)
    nmap <Leader>A <Plug>(altr-back)
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文