Textmate - how do I create a new empty file in the same folder as the current file? - textmate

With the Textmate "filesystem explorer tray" open I would like to create an empty file in the same folder as the currently open file. I cannot see a simple way of doing this barring creating a new file and then hunting through the file system in the save dialog.
Is there an easier way?

With the first document open in TextMate, type the following anywhere in that document (although a blank line works best):
mate "$TM_DIRECTORY"/mynewfile.txt
or even
mate "$(dirname "$TM_FILEPATH")"/mynewfile.txt
Then, highlight the text and hit Control-r. If it's on its own line, you don't even need to highlight it. Just be on the same line... Of course, you don't need to type that all the time. This is what we have snippets, commands and macros for!

Related

How to properly create a new file in Brackets

I know this may sound easy but I can't really get my head around this.
I just begun using Brackets for primarily writing html, scss and css. I tried going to file > new to create a new file and start typing, it did create a new file and by default it was plain text.
When I tried to change the language from the menu at very bottom right hand side of Bracket's window, I found that this option was totally disabled.I tried to save the new file, it saved it but without any file extension at the end. when I tried the saved as it only gave me two options and none of the was the language extension I intend to save my file in(All files, Web files, text files). It just saved like this (Untitled-1) instead of (Untitled-1.scss).
So how to create files like normally I would do in any other IDEs?

How do I use Mac OS aliases in Sublime Text 3?

I want to open the tree of folders which contains any code on my Mac in Sublime 3. Something like this:
But I don't have all of it in one folder, and it isn't convenient enough to open many folders in Sublime every time I close the app. So I have created 'aliases' (via Finder) to my folders and put them to one (folder), which i want to open with Sublime.
That didn't work out. Sublime opens these aliases as hex code. While ordinary folders open well.
So the main question: is there a way to make this work as I thought via preferences, or any plugin?
Use symbolic links instead by opening Terminal and using ln -s <SOURCE> <ALIAS>.
You can keep any number of folders you want collected in one place by using projects. Simply drag the folders you want, in the order you want, into the sidebar. Then, select Project -> Save Project As... and save the file anywhere you want with the .sublime-project extension. While you're at it, make sure you have
"hot_exit": true
in your user settings, as this enables you to close windows which have a project assigned to them, and all open files and unsaved changes are automatically preserved. When you next open the project, everything will be the same.

Can I use Xcode as a simple text editor?

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.
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 PROJECT I 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).
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?
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.
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.
It is possible to open the Xcode text editor on a single file from the command line.
open -a Xcode.app filename.txt
If you're going to use this a lot, you might consider making an alias in your ~/.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.
If you want to open a file in Xcode, you can also use xed.
As the man page says:
xed -- Xcode text editor invocation tool.
You can simply call xed [file] to launch Xcode editor.
Notepad++ is the way to go. Xcode was never meant to be used as a general text editor.
EDIT: Sorry, didn't know that there wasn't a Mac port for Notepad++. Use TextWrangler instead.

How do I control the "open quickly" search path in XCode3 (3.2.3)?

XCode2 had this beautiful feature: you put the cursor on a line with a #include <file> and execute the open-quickly command (command-shift-D) and it would open the file. I can't get it to work for me in XCode3.
I have something like this
#include <folder/subfolder/HeaderFile.hh>
and when I put the cursor on this line, and open the open-quickly dialog, it automatically fills the search window with
folder/subfolder/HeaderFile.hh
but doesn't find anything. If I then remove "folder/subfolder/" then the dialog will identify HeaderFile.hh and I can open it up. But this extra deleting is so much slower just the three-key command-shift-D opening I was used to with XCode2.
If I give it the full path to this file in the search window, then it finds it:
/Users/andrew/myproject/src/folder/subfolder/HeaderFile.hh
this path will find the file. Again, I don't want to spend all my time typing out the full path.
I created this project as an external build system, and I think that's related to the problem; the xcode project lives in
/Users/andrew/myproject/xcp_dir/
and I want it to search in the "../src/" directory so that the partial path I give it (which is already present in the #include) will match the file I want to open. In XCode3, I had to create the project in the xcp_dir directory; in XCode2, I could create the project directly into the existing myproject/ directory -- maybe that's why the search is failing?
I read on a previous thread (which never answered the question) that I should set the HEADER_SEARCH_PATHS option. I tried this (setting the option to /Users/andrew/myproject/src) but it did not work.
I don't have any sense of what other options (like the HEADER_SEARCH_PATHS option) are availalbe, so if you know which one I have to set, I'd love to hear it.
Since this is an old question I'll answer it for Xcode 4 instead of 3.
As far as I know Open Quickly doesn't use anything like a search path. It seems to have use the project's codesense index and will show results from that. Querying the database doesn't have an notion of file paths, so the workflow you describe just won't work anymore.
However that's okay, because there's a better solution: Just ⌘+click on the include line and the appropriate file will be found using the same rules as the compiler uses, and opened. If you want to open the file up in an assistant, another tab or window, you can use ⇧⌘+click instead, and you'll get a little UI for easily selecting where you want the file opened.
You can also use these shortcuts to go to definitions for any identifier.
If you don't want to use the mouse you can use the command "Jump to Definition" which has the shortcut ⌃⌘J, or ⌥⌃⌘J to open the definition in the assistant editor. This also works for both normal identifiers and #included files.

In TextMate, is it possible to create a new file within a project window, without having to save it first?

I have recently switched from my beloved BBEdit to TextMate because of the amazing set of features TextMate's bundles provide.
However, in BBEdit I was able to create a new file within a project window without having to save it first, while TextMate forces me to save the file before going any further. Is there any way to avoid this behaviour?
you can go from the menu with "File/New from template" this will create an Untitled file to the specified template that is not saved. However it is not in the project/project window that you currently have open. But if you think about it that is correct as if the file has not been saved TM would not know where to place it till you save it.
With Textmate 2, you can use File -> New Tab (option + command + N).
Really saving it is the only way.
To save a file in the specific directory tree:
click on the directory you want the new file to be in
press Option+Command+N
now you can Command+S
It will have that directory path.

Resources