编程时为什么要在 g(vim) 中使用制表符?

发布于 2024-10-28 23:47:44 字数 751 浏览 2 评论 0原文

像缓冲区一样使用vim的选项卡中:

这不是VIM的标签 设计用于使用。实际上,他们是 错误命名。更好的名字将是 “视口”或“布局”,因为那是 什么是标签 - 有所不同 所有窗户的布局 现有的缓冲区。

如果 vim 中的每个选项卡只是所有现有缓冲区的不同布局(因此在每个选项卡中执行 :ls ,显示相同的列表),那么 vim 中选项卡的存在是否毫无用处?如果我可以使用插件来处理MiniBufExplorer之类的缓冲区,为什么存在选项卡?在执行:ls时,至少在选项卡中打开的至少缓冲区不应该在该选项卡上显示(某种程度上像“ workspace”功能一样表现)?

我认为打开多个打开不同文件的选项卡,但是当尝试在选项卡上执行 :bn 时,它会转到所有打开的缓冲区,这会变得一团糟。有些人喜欢在开发时为问题的每个“域”打开不同的选项卡,但对我来说,如果可能的话,这将非常有用

(我搜索了很多,找不到为什么存在选项卡,只是“停止在 vim 中使用选项卡,就像其他编辑器中的选项卡一样,而是使用缓冲区”,那么为什么要在 vim 中实现选项卡?这就是为什么我不这样做认为这个问题是一个重复的)

总结...您对此主题的感觉如何 - 编程时Tabs在VIM中的有用性?你如何使用它?

In Using vim's tabs like buffers:

This is not how vim's tabs are
designed to be used. In fact, they're
misnamed. A better name would be
"viewport" or "layout", because that's
what a tab is -- it's a different
layout of windows of ALL of your
existing buffers.

If each tab in vim is just a different layout of all existing buffers (so doing :ls in each tab, shows the same list), isn't the existence of tabs in vim useless? If I can use plugins to handle buffers like minibufexplorer and such, why do tabs exist? Shouldn't at least buffers opened in a tab be shown when doing :ls only on that tab (acting somehow like a "workspace" feature)?

I think that having multiple tabs with different files opened, but when trying to do :bn on the tabs it goes to all opened buffers, it becomes a mess. Some people like to open different tabs for each "domain" of problem when developing, but I to me it would be really useful if it was possible to have a different buffer list for each tab in Vim.

(I have search SO a lot, and couldn't find WHY tabs exist, only "stop using tabs in vim like tabs in others editors, use buffers instead", so why do tabs in vim were implemented? That's why I don't think this question is a duplicate)

Summarizing... How do you feel about this subject - usefulness of tabs in Vim when programming? How do you use it?

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

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

发布评论

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

评论(3

往事随风而去 2024-11-04 23:47:44

每个选项卡都可以有自己的工作目录,这使得分组和处理类似的文件组更加方便。

另外,直接来自 :help tabpage

Tabs are also a nice way to edit a buffer temporarily without changing 
the current window layout.  Open a new tab page, do whatever you want
to do and close the tab page.

Tabs can each have their own working directory which makes grouping and working with similar groups of files much more convenient.

Also, directly from :help tabpage:

Tabs are also a nice way to edit a buffer temporarily without changing 
the current window layout.  Open a new tab page, do whatever you want
to do and close the tab page.
只怪假的太真实 2024-11-04 23:47:44

我经常使用选项卡,并使用它们对文件进行逻辑分组。

例如,我将在一个选项卡中打开视图或 HTML,在另一个选项卡中打开关联的控制器,在另一个选项卡中打开关联的模型。然后,我将使用 :mksession! 保存布局,并稍后使用 -S 标志重新加载它。

其他时候我会使用选项卡来保持 vim 的帮助页面之一打开,以便立即可用。

我认为最主要的是选项卡允许您以与使用分割窗口不同的方式组织缓冲区,并且这种灵活性允许 vim 与更多人的大脑一起工作,因为我们都有不同的想法。

对相关问题的回答可能会有所帮助:像缓冲区一样使用 Vim 的选项卡

我通常使用 -O 标志在拆分窗口中打开文件,但如果您坚持在单独的选项卡中打开它们,则可以使用 -p。我更喜欢拆分,因为我可以轻松地并排看到两个单独的文件,这是使用选项卡无法做到的。

最后,这里有一些我用来方便在分割之间移动的关键定义:

" Switch between window splits using big J or K and expand the split to its
" full size.
"
" Move vertically in the window through the horizontal splits...
map <C-J> <C-w>j<C-w>_
map <C-K> <C-w>k<C-w>_

" Move horizontally in the window through the vertical splits...
map <C-H> <C-w>h<C-w>\|
map <C-L> <C-w>l<C-w>\|

I use tabs often, and use them to logically group files.

For instance, I'll open views or HTML in one tab, in another have the associated controllers and another has the associated models. Then I'll save out the layout using :mksession! and reload it later with the -S flag.

Other times I'll use tabs to keep one of vim's help pages open just so it's immediately available.

I think the main thing is tabs allow you to organize your buffers in a different way than using split windows and that flexibility allows vim to work with more people's brains, because we all think differently.

This answer to a related question might help: Using Vim's tabs like buffers

I normally use the -O flag to open files in split windows, but if you insist on opening them in separate tabs you can use -p. I prefer splits because I can easily see two separate files side by side, something you can't do with tabs.

And finally, here's some key defs I use to make it easy to move between splits:

" Switch between window splits using big J or K and expand the split to its
" full size.
"
" Move vertically in the window through the horizontal splits...
map <C-J> <C-w>j<C-w>_
map <C-K> <C-w>k<C-w>_

" Move horizontally in the window through the vertical splits...
map <C-H> <C-w>h<C-w>\|
map <C-L> <C-w>l<C-w>\|
皓月长歌 2024-11-04 23:47:44

当我当前的视图被尽可能多地分割时,我通常会使用选项卡,同时仍然允许我有效地阅读和编程。大多数时候它就在那里,以便我可以快速访问该文件的信息(通常是某种包含文件)。

我很少使用选项卡进行实际开发,而是使用占位符来存放我偶尔想查看的信息。

所以通常我有

Tab0 ->源文件和测试文件
选项卡1->包含文件,有时还有相关的接口文件

I normally use tabs when my current view is split as much as it can while still allowing me to read and program efficiently. Most of the time it is there so that I have quick access to the information of that file (generally some kind of include file).

I rarely use tabs for actual development but rather a placeholder for information that I want to occasionally look at.

So normaly I have

Tab0 -> source file and test file
Tab1 -> include file and sometimes a related interface file

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