有没有一个工具可以在单个文件中编辑相关代码?
我的想法是,当相关代码位于单个“工作”文件中时,编辑相关代码要容易得多。例如,在 Rails 应用程序中,当您实现某些功能时,您可以在以下文件中为每个文件编辑 1 个函数:集成测试、控制器测试、控制器、模型、控制器助手。因此,如果可以 1) 标记此代码片段 2) 自动将它们收集到“工作”文件中 3) 将它们编辑在一起 4) 该工具同步(放回)更改;在许多情况下它可以简化开发过程。特别是如果您需要进行多次周而复始的迭代。
My idea is that it's much easier to edit related code when it sits in single "work" file. E.g. in Rails application when you implementing some functionality you may edit 1 function per file in the following files: integration test, controller test, controller, model, controller helper. So if it would be possible to 1) mark this code fragments 2) automatically collect them in "work" file 3) edit them togather 4) the tool synchronizes (puts back) the changes; it could simplify development process in many cases. Especially if you need to go through many tweek-and-try iterations.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Vim 可以很好地解决这个问题。安装 Rails.vim(1) 插件并使用命令 :AV 您可以打开带有随附测试/规范的垂直拆分,或 :RV 打开相关文件,例如迁移和视图(取决于您是否正在查看模型或控制器) )。当您的工作空间变得混乱时,请使用 :only 返回到一个文件。恕我直言,拆分是管理多个相关文件的最佳方式。您甚至可以打开同一文件两次以查看同一文件的两个部分。与您描述的不完全相同,但很接近。
1: http://rails.vim.tpope.net/
Vim works fine for this. Install the Rails.vim(1) plugin and with the command :AV you can open a vertical split with the accompanied tests/specs, or :RV to open related files like migrations and views (depending on whether you're viewing model or controller). When you're workspace becomes to cluttered, use :only to go back to one file. Splits are the best way to manage multiple related files IMHO. You can even open the same file twice to see two parts of the same file. It's not exactly the same as you are describing, but it comes close.
1: http://rails.vim.tpope.net/
只需打开 Vim 并打开一些窗口即可。有什么问题吗?
Just open up Vim and open some windows. What's the problem?