简体   繁体   English

像串联一样编辑文件——是否有任何 IDE 或文本编辑器具有此功能?

[英]Edit files as if concatenated as one -- Do any IDEs or text editors have this feature?

Background: I am working with Angular (but my problem is not particular to any language or framework).背景:我正在使用 Angular (但我的问题并非特定于任何语言或框架)。 In Angular, each component requires four separate files.在 Angular 中,每个组件需要四个单独的文件。 So, we often find ourselves with 40+ files open.因此,我们经常发现自己打开了 40 多个文件。 But, most of these files can be tiny, less than 20 lines each.但是,这些文件中的大多数可能很小,每个不到 20 行。

Many IDEs allow you to open your files in multiple windows.许多 IDE 允许您在多个 windows 中打开文件。 Each window can have a different panel, and each panel can have different tabs.每个 window 可以有不同的面板,每个面板可以有不同的选项卡。 This is great, but honestly, still isn't enough.这很棒,但老实说,这还不够。

What I want: In addition to windows, panels, and tabs, I'd like to add another level of organization.我想要什么:除了 windows、面板和选项卡之外,我还想添加另一个层次的组织。

I speculate this has probably existed for decades, but I just don't know what it's called .我推测这可能已经存在了几十年,但我只是不知道它叫什么 At the very least, I speculate this has existed at least since Angular was a thing.至少,我推测这至少在 Angular 出现时就已经存在。

For example, here is a screenshot of VSCode with four files open across four panels.例如,这是 VSCode 的屏幕截图,其中四个文件在四个面板中打开。 (Code taken from Angular dynamic component tutorial): (代码取自 Angular 动态组件教程):

VSCode 的屏幕截图,其中四个短文件在四个面板中打开

And here is a quick mockup showing what I'm looking for.这是一个快速模型,显示了我正在寻找的内容。 Four files are open, but the three shortest ones are "concatenated" into one editor.四个文件是打开的,但最短的三个文件被“连接”到一个编辑器中。 Arrow-key down from the bottom of one file will bring you to the first line of the next file.从一个文件底部向下的箭头键会将您带到下一个文件的第一行。

VSCode 的屏幕截图,其中打开了四个短文件,三个在一个窗格的单个编辑器中,一个具有专用窗格。

Notably, these files are not actually concatenated on-disk.值得注意的是,这些文件实际上并没有连接到磁盘上。

TLDR: What text editor can allow me to edit multiple files as if they were concatenated, as in the mockup above? TLDR:什么文本编辑器可以让我像在上面的模型中那样编辑多个文件,就像它们被连接一样?

If the files stay as separate windows/tabs, the file editor would have to shrink each tab to a minimal height, and then tile them vertically.如果文件保留为单独的窗口/选项卡,则文件编辑器必须将每个选项卡缩小到最小高度,然后垂直平铺它们。 If any editor can do it, I suspect it would be emacs or vim.如果有任何编辑可以做到,我怀疑它会是 emacs 或 vim。 You might also be able to do it by opening separate editor windows and using a tiling window manager.您也可以通过打开单独的编辑器 windows 并使用平铺 window 管理器来完成此操作。

We can achieve a similar effect with some text editing magic.我们可以通过一些文本编辑魔法来实现类似的效果。 It would be something like:它会是这样的:

  • Add a header to each file consisting of a unique separator (eg # === magic separator === filename my_file.js === )将 header 添加到由唯一分隔符组成的每个文件(例如# === magic separator === filename my_file.js ===
  • Use cat to combine all the files into one file使用cat将所有文件合并为一个文件
  • Edit this one file编辑这个文件
  • When done, use the separator to break them up and put the text back into the original files完成后,使用分隔符将它们分开并将文本放回原始文件中

You could easily write some scripts for combining and splitting so you can do it quickly.您可以轻松编写一些用于合并和拆分的脚本,以便快速完成。 You can also set up a background script that automatically runs the splitter as you edit the combined file.您还可以设置一个后台脚本,在您编辑组合文件时自动运行拆分器。 However, the combined file would essentially be a new file, so you could not view changes on it with git, and VS Code's CodeLens/Inline blame wouldn't work.但是,合并后的文件本质上是一个新文件,因此您无法使用 git 查看其上的更改,并且 VS Code 的 CodeLens/Inline 责备不起作用。

One option would be to develop your codebase with the combined files checked in to VCS, and then only have the splitter script as part of your "build" step.一种选择是使用签入 VCS 的组合文件开发代码库,然后仅将拆分器脚本作为“构建”步骤的一部分。 So you would make your changes, run ./build.sh which splits the files into some temp directory, and then run your application from there.因此,您将进行更改,运行./build.sh将文件拆分到某个临时目录中,然后从那里运行您的应用程序。

Lastly, and I hate to be snide, but the fact is that this problem is best solved by avoiding poorly designed frameworks that do not consider developer ergonomics.最后,我讨厌被冷嘲热讽,但事实是,最好通过避免不考虑开发人员人体工程学的设计不佳的框架来解决这个问题。 Many other languages give the developer much freedom and many tools to organize their code as they wish, rather than imposing constraints like requiring many small components to be in separate files.许多其他语言为开发人员提供了很大的自由度和许多工具来按照他们的意愿组织他们的代码,而不是像要求许多小组件在单独的文件中那样施加约束。 Java for example also had a similar problem (dunno if more recent versions fixed it) - you can only have one class per file, which creates a huge mess if you like having many small files.例如 Java 也有类似的问题(不知道是否有更新的版本修复了它) - 每个文件只能有一个 class,如果你喜欢有很多小文件,这会造成巨大的混乱。 C# does not have this limitation and as a result C# codebases can be much tidier than Java codebases. C# 没有此限制,因此 C# 代码库可以比 Java 代码库更整洁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否有任何文本编辑器/ IDE一般支持语言? - Are there any text-editors/IDEs that support languages generically? 你是否区分了文本编辑器和IDE? - Do you draw a distinction between text editors and IDEs? 是否有任何 IDE/IDE 插件支持 JavaScript CommonJS 模块? - Do any IDEs/IDE plugins have support for JavaScript CommonJS modules? 是否有任何内置支持编译 ILASM 文件的商业或开源 IDE? - Are there any commerical or open source IDEs that have built-in support for compiling ILASM files? 任何R IDE都支持条件断点吗? - Do any R IDEs support conditional breakpoints? 是否有任何Python IDE支持类型提示或函数参数的有限代码完成功能? - Do any Python IDEs have support for type hinting or limited code completion for function arguments? 您是否知道任何本地化为西班牙语的IDE? - Do you know of any IDEs that are localized to Spanish? 哪些IDE和文本编辑器可以推断出在C ++ 11中使用auto关键字声明的变量类型 - Which IDEs and text editors can deduce type of variables declared using auto keyword in C++11 编程IDE /编辑器中垂直条的目的 - purpose of vertical bar in programming IDEs/Editors IDE和编译器的/ t间距是否不同? (IntelliJ上的JAVA) - Do IDEs and compilers have different spacing for /t spacing? (JAVA on IntelliJ)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM