如何在处理多个文件时组织 Vim 缓冲区、窗口和选项卡

发布于 2024-09-26 01:47:44 字数 248 浏览 0 评论 0原文

我一生都在使用 VIM,但最近我有点厌倦了它,因为在一个大项目(有 500k LOC 和数百个文件)中同时处理 20 个左右的文件时,我迷失在缓冲区、窗口和选项卡中。

每当我执行 :make:grep 等操作时,新的缓冲区就会在当前窗口中跳出。 标签也会发生同样的情况。在某些时候,这开始变得非常混乱,因为我确实必须关注 VIM 中的事物所在的位置。

有哪些行之有效且简单的方法可以控制这种行为?

I used VIM whole my life but recently I am a bit tired of it because I am lost in buffers, windows, and tabs when working simultaneously with 20 files or so in a big project (with 500k LOC, and hundreds files).

Whenever i do :make, :grep, etc, new buffers are jumping out in the current window.
The same happens for the tags. At some point this starts to be very confusing because I really have to focus where things are in a VIM.

What are a proven and easy ways to control this behavior?

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

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

发布评论

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

评论(5

一场信仰旅途 2024-10-03 01:47:44
  • 使用 :hide 删除所有窗口,除非您确实需要打开它们。

  • 我不确定为什么标签要为您创建一个新窗口,CTRL+] 应该重新使用当前窗口。

  • nnoremap + 4+nnoremap - 4- 与标准 一起使调整窗口大小变得更加容易;_|

  • 获取 22 英寸显示器(最小)并使用 :vsplit 并排显示文件。我发现这比拥有两个较小的显示器更重要。

  • 使用LH等来移动窗口。不要忘记 :tab sp 在新选项卡中打开当前文件(或新文件)。

  • <代码>:地图<左>h 和 :mapl 等使得在窗口之间移动更加容易。 :map; :tabprev:map:tabnext 使在选项卡之间移动更加容易。

最后,如果您需要定期打开 20 个文件,这可能表明您的代码组织不良。如果可能,功能应包含在单个文件中,那么您只需一次将工作重点放在一项功能上。

  • Use :hide to get rid of all windows unless you really need them open.

  • I'm not sure why tags are creating a new window for you, CTRL+] should re-use the current window.

  • nnoremap + 4<C-W>+ and nnoremap - 4<C-W>- make it much easier to resize windows, along with the standard <C-W>_ and <C-W>|.

  • Get a 22" monitor (minimum) and use :vsplit to show files side by side. I find this is even more important than having two smaller monitors.

  • Use <C-W>L, <C-W>H etc to move windows around. Don't forget :tab sp to open the current file (or a new one) in a new tab.

  • :map <LEFT> <C-W>h and :map <RIGHT> <C-W>l, etc make it much easier to move between windows. :map <C-LEFT> :tabprev<CR> and :map <C-RIGHT> :tabnext<CR> make it much easier to move between tabs.

And finally, if you need to have 20 files open regularly, this could be a sign that your code is poorly organized. If possible, features should be contained within a single file, then you just need to focus work on one feature at a time.

攒一口袋星星 2024-10-03 01:47:44

不久前,我为朋友测试了 Eclim http://eclim.org/。基本上,它允许您在无头模式下运行 Eclipse,同时使用 vim 进行编辑等。通过扩展,它允许 Vim 充分利用两个领域的所有优势,例如将 Eclipse 的项目树添加到您最喜欢的编辑器中!

当时的安装有点令人畏惧,但一旦我安装并运行它,它真的很顺利,而且是一个非常出色的解决方案。尝试一下,我确信您不会失望的。现在安装可能更容易了。 :)

哦,我还应该提到有几个 Eclim 设置。您可以拥有以 vim 作为主要界面的无头 Eclipse(正如我首先提到的),您可以拥有有头 Eclipse 和 Vim,这样您就可以轻松地来回切换(在同一个项目中同样如此),或者您可以拥有 Vim集成到 Eclipse 本身中。

I tested out Eclim http://eclim.org/ a while ago for a friend. Basically, it lets you run Eclipse in a headless mode while using vim for editing and so on. With the extension, it allows Vim to draw on all the strengths of both worlds, adding for instance Eclipse's project tree to your favourite editor!

Installation was a bit daunting back then, but once I had it up and running, it was really smooth and quite a brilliant solution. Try it out, I'm pretty sure you won't be disappointed. And the installation is probably easier now. :)

Oh, I should also mention that there are several Eclim-setups. You can have headless Eclipse with vim as your primary interface (as I first mentioned), you can have a headed Eclipse and Vim, so that you can easily switch back and forth (in the same project no less), or you can have Vim integrated into Eclipse itself.

寂寞笑我太脆弱 2024-10-03 01:47:44

运行多个 vim。我在我的 Linux 机器上使用“konsole”。它允许我在一个窗口中打开许多选项卡式 Linux 终端会话。我可以双击选项卡来命名它们,例如“模型”、“视图”、“控制器”等。在每个选项卡式 Linux 终端中,我将运行一个 vim 进程,该进程通常在以下位置打开 2 或 3 个文件:一次。
另一个选择是找到具有 Vim 模式的 IDE,这样您仍然可以使用大部分关键命令。

Run multiple vims. I use "konsole" on my Linux machine. It allows me to open many tabbed linux terminal sessions in one window. I can double click the tabs to name them, e.g. "models", "views", "controllers", etc. In each of these tabbed linux terminals, I'll have a vim process running that has usually 2 or 3 files open at a time.
Another option is to find and IDE that has Vim mode, so you can still use most of your key commands.

转角预定愛 2024-10-03 01:47:44

作为一名长期的 vim 用户,我说起来很痛苦,但是——也许你是时候升级到成熟的 IDE 了。在大多数情况下,您仍然可以使用 vim 作为编辑器,但 IDE 将为您处理文件管理和导航,并且可能会简化您的 make 和 grep 工作流程(例如,结构搜索胜过 grep)。您使用什么语言进行工作?

As a longtime vim user, it pains me to say it, but--it might be time for you to graduate to a full-fledged IDE. You can still use vim as your editor in most cases, but the IDE will handle file management and navigation for you, and probably will simplify your make and grep workflows (e.g., structural search beats the pants off of grep). What language are you working on?

一生独一 2024-10-03 01:47:44

Vim-CtrlSpace 可让您组织选项卡、缓冲区、会话(工作区)+ 模糊搜索。< br>
非常适合从事大型项目。这就是我实际上想出的方法。
之前,我使用了 'jlanzarotta/bufexplorer.git' 和 'xolox/vim-session'

你可以检查 YouTube 上的演示

Vim-CtrlSpace lets you organize Tabs, Buffers, Sessions (workspaces) + fuzzy search.
It is quite suitable to work on large projects. That's how I actually come up with it.
Before, I used 'jlanzarotta/bufexplorer.git' and 'xolox/vim-session'

You can check the demo on YouTube.

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