我可以将 Xcode 用作简单的文本编辑器吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14650232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:41:37  来源:igfitidea点击:

Can I use Xcode as a simple text editor?

xcodetext-editor

提问by RichWalt

Okay ... This may be a ridiculous question. (I'm still getting used to Mac.) I really like the auto fill-in-ahead predictive typing feature of Xcode.

好吧......这可能是一个荒谬的问题。(我还在习惯 Mac。)我真的很喜欢 Xcode 的自动预填预测输入功能。

Can I use it to simply edit files laying around different locations on my hard drive? I do not really want to create a project or anything (unless by PROJECTI mean simply loads several files, that are not related to each other, but that I may want to jump back and forth in editing them- I do not want to create a project from files that need to be compiled or anything).

我可以使用它来简单地编辑位于硬盘驱动器上不同位置的文件吗?我真的不想创建一个项目或任何东西(除非通过PROJECT我的意思是简单地加载几个彼此不相关的文件,但我可能想在编辑它们时来回跳跃- 我不想创建来自需要编译的文件或任何东西的项目)。

If so, what's the best way to get started? When you open XCode, it asked a lot of wizard questions to get things set up. How would I simply get started to edit 5 or so files at a time ... where I might want to switch back and forth between them - and they are not in the same directory?

如果是这样,最好的入门方法是什么?当您打开 XCode 时,它​​会询问很多向导问题以进行设置。我将如何简单地开始一次编辑 5 个左右的文件......我可能想在它们之间来回切换 - 而且它们不在同一目录中?

All I want to do is simply make changes and save them, make more changes and save again, repeat. Kind of like holding a lot of shell scripts that communicate with each other.

我想要做的就是简单地进行更改并保存它们,进行更多更改并再次保存,重复。有点像持有大量相互通信的 shell 脚本。

Okay ... so I know this was a silly question - but Xcode is so intimidating for newbies. Sometimes, one needs a place to just get started and I haven't found that yet.

好的...所以我知道这是一个愚蠢的问题 - 但 Xcode 对新手来说太可怕了。有时,人们需要一个刚刚开始的地方,而我还没有找到。

回答by Kent A.

It is possible to open the Xcode text editor on a single file from the command line.

可以从命令行在单个文件上打开 Xcode 文本编辑器。

open -a Xcode.app filename.txt

If you're going to use this a lot, you might consider making an alias in your ~/.bashrc.

如果你打算经常使用它,你可以考虑在你的 ~/.bashrc 中创建一个别名。

alias xc="open -a Xcode.app"

As of Xcode 6, you cannot open a directory this way, as it will give you an error message stating that directories must be opened as part of a project. If you provide more than one file on the command line, Xcode appears to create a temporary project containing the files you provided. You can add files and folders to the temporary project, but there doesn't seem to be a way to save the temp project for use later.

从 Xcode 6 开始,您不能以这种方式打开目录,因为它会给您一条错误消息,指出必须将目录作为项目的一部分打开。如果您在命令行上提供多个文件,Xcode 似乎会创建一个包含您提供的文件的临时项目。您可以将文件和文件夹添加到临时项目,但似乎没有办法保存临时项目以供以后使用。

回答by Shunzhe M

If you want to open a file in Xcode, you can also use xed.

如果要在 Xcode 中打开文件,也可以使用xed.

As the man page says:

正如手册页所说:

xed -- Xcode text editor invocation tool.

xed -- Xcode 文本编辑器调用工具。

You can simply call xed [file]to launch Xcode editor.

您可以简单地调用xed [file]以启动 Xcode 编辑器。

回答by David

Notepad++ is the way to go. Xcode was never meant to be used as a general text editor.

Notepad ++是要走的路。Xcode 从未打算用作通用文本编辑器。

EDIT: Sorry, didn't know that there wasn't a Mac port for Notepad++. Use TextWrangler instead.

编辑:抱歉,不知道 Notepad++ 没有 Mac 端口。请改用 TextWrangler。