Author Topic: Scratch buffer or unnamed file?  (Read 2976 times)

mwb1100

  • Senior Community Member
  • Posts: 156
  • Hero Points: 13
Scratch buffer or unnamed file?
« on: September 10, 2014, 01:47:21 AM »
Is there a way for SE to create a scratch buffer that is not associated with named file?  I often want to have a scratch file for some temporary work that I'm not interested in having on the file system.  For example, I might just want to paste something from the clipboard, edit it a bit then copy the result back onto the clipboard and into something else.

When I do a Ctrl-N (or press the toolbar button), I get a dialog that forces me to name a file in a specified place on the file system before I get  to actually do anything else (as an aside - why can't I give the entire path-and-file name in one edit field in this dialog?).  I'd prefer if the actual naming and location of the file were deferred until I want to save it.  Many - maybe even most - text editors behave this way.

If this isn't possible through an existing SE command that I can create a menu entry or toolbar button for, does anyone have a macro they can share?  If an unnamed buffer isn't possible, then I'd certainly settle for a macro that will create a new file in a specified directory (maybe something that takes its default from the TMP or TEMP environment variable) with a name generated by some template and/or incrementing a number or even a randomly generated name for a file that doesn't already exist in the location.

I'm by no means proficient with SE macros, so any pointers would be appreciated.

Thanks.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6868
  • Hero Points: 528
Re: Scratch buffer or unnamed file?
« Reply #1 on: September 10, 2014, 02:50:01 AM »
You don't have to name the file but you do have to uncheck "Add to Project" which doesn't support files with no name.

There is also a command called "new-file" which simply creates a file with no name. The argument is the mode. "new-file ?" will display all the mode arguments. I've never used this command.

I live on this command: "e +t" which also gives you advanced switches like choosing encoding and line endings without getting prompted ("e +futf8 +t" or "e +fu +t"). What I do when I want to give a name is just type something like "e sdf.cpp". By specifying a file with an extension, the mode is automatically set. Since the file is not found, a new file is created and I get the mode I want.

mwb1100

  • Senior Community Member
  • Posts: 156
  • Hero Points: 13
Re: Scratch buffer or unnamed file?
« Reply #2 on: September 10, 2014, 03:35:08 AM »
Thanks.  That seems obvious.

I think I overlooked "new_file" in the help because I was so sure the command I was looking for would be named "new_buffer" for not having a file associated with it. Sometimes when you *think* you know the answer, you start to overlook what you should see.

I also actually *did* see and even tried out the "new" command, but it brought up the dialog I was trying to avoid.

I guess I have mostly used SE only with projects, which is why I thought the "new" dialog always forced a filename. I'm starting to use SE as a replacement for my more basic editors too, so I'm lurching and stumbling to finding out how to do things without projects like just compiling and running the active C file.  I just found out this was actually very easy to do in a tip that got reposted on the forum several weeks back. Until then I thought building was a project-only functionality, and that I'd have to hack on a custom macro to do what I wanted.

It's also clear that I need to get more familiar with the command line in SE - so far I've been avoiding it, which is undoubtedly a mistake.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6868
  • Hero Points: 528
Re: Scratch buffer or unnamed file?
« Reply #3 on: September 10, 2014, 11:40:02 AM »
What you'll find is that there are a few commands worth knowing how to use. The "e" command is one of them.