Lightning Fast Folder and File Creation in Sublime Text 2
videos

Lightning Fast Folder and File Creation in Sublime Text 2

Tutorial Details
  • Format: Video
  • Length: 4:47
  • Difficulty: N/A

I’m frequently asked about how I’m able to create new directory structures and files so quickly in Sublime Text 2. Well the answer is that this functionality is not offered natively; instead, I use a helpful plugin. I’ll demonstrate it in this video.

Choose 720p for the clearest video.

Closing Thoughts

It’s worth mentioning that, toward the end of the video, I assign a custom key-binding: n-n. Please note that this binding assumes that you’re working in Vintage (Vim) mode. To trigger it, you’d exit to command mode – by pressing Esc – and then type n-n.

If you’re not a Vintage user, you can stick with the default key-binding that comes with the plugin.

Show Links

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Cusco

    it doesn’t work on Windows … the path name is wrong while creating it become “C::\” which have double ::

    • Youssef Boubdir

      Same problem, dont work on Windows

      • http://pressedweb.com Cory

        Confirmed broken in Win7.

    • Maikel

      Same for me. Win7

    • http://jnericks.com Jon

      Same, broken in Win7

    • El garch

      doesn’t work on Windows when we have more than one project!

  • Patrick

    It doesn’t save the file giving me an error saying that it is unable to save the file I just created. It’s probably because it doesn’t exist. I followed the exact instructions for the instalation and it should work just fine. But no. It cannot save the file.

  • Tim

    I have the same problem, it doesn’t work on Windows.

  • chichibek

    great job. thanks once again!

  • http://pressedweb.com Cory

    Cool tip. Can Fetch fetch from the user’s hard drive yet?

    I’ve got a method for creating projects where I put a .zip (wish Fetch didn’t need packages to be a .zip as well – a normal folder should work) of my project folder on my CDN, then fetch it and it works like a charm, but it sucks I’m paying for that storage/bandwidth on my CDN (granted it’s negligible).

    I’ve noticed you pushing Fetch a lot, but there are just a few… tiny… tiny…. things that could be upgraded on it to make it indispensable. I think everyone is still waiting on that.

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      No – no hard drive access yet.

    • http://about.me/weslly Weslly

      You can fetch local files by using the “file://” protocol.

      • http://pressedweb.com Cory

        Awwwwwwwwwwwwwwwwwwwwwwwwwwwwwwesome. :)

        Fetch is my new fav plugin. :)

        Off to make a million packages for myself.

  • Thomas Jane

    Should I use Vim or Sublime Text 2. Which one has developer-friendly feature and more of them.

    • http://oscargodson.com Oscar Godson

      Sublime is far more developer friendly, but VIM is (i’d say) more powerful. I used Sublime for probably close to a year a switched to VIM simply for the fact I can do more without using my mouse. Also, there’s VIM support in Sublime but it’s limited.

      I’d say to play with both and see which you like. They’re on totally different playing fields. To ease the change you could also try using iTerm which allows you to do some mouse stuff (like scrolling and highlighting) You can also use the Sublime theme in VIM (which I do) and fonts. http://winterdom.com/2008/08/molokaiforvim

    • http://redcrown.co Matthew

      Sublime text seems faster than vim when it comes to fuzzy searching files, and also seems to be smarter when opening files with a GUI, I.e drag and drop.

      However I feel vim is much more powerful. I’ve bee trying out st this week with vintage mode, but there are some simple things I miss tremendously. Perhaps, there are plugins for these things but I haven’t found them.

      Being able to enter “search” mode while in visual mode.
      Being able to browse sidebar with vim keys, jkhl. (nerd tree in vim).
      Easymotion plugin.
      Much easier editing of key bindings. (I still can’t figure out how to change the binding for zen coding in st2).
      Easier to find documentation. (I find the st forum seriously lacking).

      I’ll give st2 another week,

      Ps . A similar feature to this for file creating is offered with the ctrlp plugin for vim. It has tab completion and such too.

  • Brad

    I love these Sublime 2 tutorials, look forward to more things like Fetch

  • http://www.leonzhang.com hileon

    If SideBarEnhancements plugin installed, press `Ctrl+t` will show up new file option. Then input , if directory does not exist, it will be created automatically.

  • https://plus.google.com/111051633394455678705/posts Artem

    Windows bugfix:
    Open AdvancedNewFile.py and replace this:
    self.window.run_command(‘open_file’, {“file”: file_path})
    with this:
    self.window.open_file(file_path)

    • http://pressedweb.com Cory

      Awesome! Works as expected now.

      Look at the big Python on you! …Er….

      Now how do I make the default root folder my C:\Users\Foo\Desktop? :)

      • http://28inch.co.uk 28inch

        I always use ‘file/open folder’ and all the new files/folders will be relative to that one.

    • http://www.28inch.co.uk/ 28inch

      Cheers mate! It works for me now!

    • Tim

      Thanks!

    • Patrick

      Here’s the thing. I had that line of code you mention that we should replace written in the file, not the “self.window.run_command(‘open_file’, {“file”: file_path})”, and although it didn’t work yesterday evening, it works now. I guess all it took was a reboot. :))

      Great plugin, anyway! Very helpful.

  • Keg

    its now possible use zen codding in sublime on file with any extension? a few months ago i tried sublime and zen coding and it works only on some extensions (not on .phtml, etc.)

  • Rober

    Good day! I like very much some of your tutorials. I am new at this and I hope you can add a tutorial about how to create our own WP themes because it is hard to find free Wp themes created with style and the great ones costs. What I found so far disappoint me. Thanks!

    • http://N/A Gabriel Dubois

      Hi,

      I stumbled across your reply, and decided to share a bit of wisdom. First of all, nothing good is free! A well designed, updated and bug free anything is highly unlikely to come around.
      Creating a WordPress theme is a time consuming, labor intensive and too often you stumble into a dead end with your code. This would inevitably lead to forum posts, people getting involved and so on.

      I don’t think a tutorial is going to help you – especially since you don’t sound like a hardcore programmer. WP themes aren’t something you easily jump into. I know of a lot of archives, like http://www.wptmp.com, which offer thousands of themes ( most of them are basic, but it’s enough to get you started).

      Then there are paid services, like theme forest, and envato’s marketplace; and if you don’t want to pay for quality themes, you can always search for user-submitted themes, on public asset portals, like http://www.creattor.com, where you can find free, quality stuff. I give this advice to a lot of starting designers and developers: experiment!

      P.S. I don’t know if this type of post is adequate for this type of article. Cheers!

      Don’t let others do your work for you.

  • http://fat-news.mihanblog.com/post/2011 پکن خواستار

    This is so nice answer to that questions you get :)
    Nice tutorial. Thanks for sharing.

  • Matthew

    How do you get that side bar right click menu? I just get “close” when I right click there. Is that a plugin as well?

  • http://richardmisencik.com Richard

    Hey Jeffrey,

    Great tip, exactly what i wanted to know :).
    I have one problem though, I just installed Sublime Text (dev build 2195), then installed Package control, restarted and the problem is when I select “Install package” and press enter, nothing happens. I cant install any plugins. Any idea what might be the problem? Thanks.

  • Andie

    Yaay, works on windows now. Good one Jeff !

  • http://pressedweb.com Cory

    Here’s how I can load a myriad of different projects to my sidebar in about 3 seconds using Fetch and a CDN (it’d be a lot cooler if Fetch could fetch from HD *hint hint wink wink* but until then…).

    http://pressedweb.com/tutorials/sublime-text-2-cdn-quickstart-projects/

    • http://pressedweb.com Cory

      Bleh, I’m stupid, you don’t need a CDN at all, you can use “file:///C:/Users/my_username/Desktop/my_package.zip” instead. :)

  • peter

    I also recommend “Quick File Creator” Plugin for ST2. It’s great and fast too. Chec it!

  • http://kalexiko.com Lee

    Hey all, I usually achieve this by right clicking, click new file then entering the path, “application/assets/css/style.css” and it will create the directories for me. Correct me if I’m wrong but this is default functionality.

  • http://kingluddite.com Pip

    Jeffrey,

    As always, your tutorials rock. I did get lost when you quickly mentioned ‘vintage mode’ as I have no idea what that is. I couldn’t get your ‘n n’ shortcut to work so I just added the shortcut to make it work:

    { “keys”: ["alt+super+n"], “command”: “advanced_new_file”},

    Vintage mode sounds interesting. Could you create a tutorial showing us how to use it and the benefits of using it? Or if you did create a tutorial on this, could you point us to the URL?

    I also like your new snippet shortcut. All your tips are saving me so much time. Please keep them coming.

  • Rory

    can you create siblings?

    assets/css/style.css+fonts.css+reset.css

    that would be handy. Or

    assets/css+images+(js/libs)

  • Rober

    Thank you very much for your reply, Gabriel. It really helped me a lot. The first link didn’t please my needs but then I checked up the second link, creattor and it was exactly what I want. Thnaks for the tip, I thought the friendly people disappear, no one replied in so many days. Cheers to you man!

  • mrgstiffler

    What’s the best way to add more file/folder control? I would love to be able to drag files between folders inside of Sublime.

  • http://pintarkomputer.net kade

    Nice, tutorial jeff..
    i learn many things from you.

  • http://maximmcnair.com Maxim

    To create a file in a folder you can simple click “New File” then type “*folder*/*file*”.

  • jamaica

    can you guys please help me on how to repair or recover a damaged External hard disc, I have a lot of the but they are all of the same problem, please help

  • http://www.webmasterdubai.com webmasterdubai

    hi jeffery can you help me how to use this plugin https://github.com/Nijikokun/Prevu preview in browser web pages

  • Alex Rodrigues

    Hey Jeff. I don’t seem to have the folders section in my sidebar, only the files. Any idea what could fix this? I’m using WinXP

  • http://well.blogs.nytimes.com Chris

    Great Tut! I just started using Sublime this past week just to see what all the hype was about. So far I really like it and the plug ins.

  • http://subash.com.au subash

    I did enter the command mode by pressing jj. But how do I exit back to insert mode??

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Press Escape.

  • http://www.skippaz.com Kaske

    It doesn’t work on Windows XP SP3.

    * I activated the Vintage mode and it showed Insert at the left bottom
    * I entered the key bindings exactly as suggested
    * When I hit “j, j” it doesn’t enter the command mode BUT when I hit escape it enter’s it. The problem is I can’t go back to Insert mode by hitting escape again nor it responds to “j, j”
    * It doesn’t recognize the “n, n” shortcut saying: “Unable to find self.window.run_command”

    Any suggestions, please?

  • Ryan

    Jeffrey,
    You also have used a shortcut to auto-populate your standard html(doctype/head/title/link/body). Are you just using Fetch to do that (with another keybinding if so) or is there more trickery to that?

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Just custom snippets in Sublime Text.

  • Adrian Oprea

    The plugin is absolutely amazing, I find it very veeery useful but, if you have multiple in your sidebar, it creates the folder/file in the first project. I’m not saying that you should work on multiple projects at the same time, to me this sounds like a real bad practice, but let’s say that you’re lazy and you keep multiple projects in your sidebar just so you can access them quicker, and you jump from project A to project B and want to create a file. I took a look in the source of the plugin and my guess is that the get_root() function/method, only gets the first open folder:

    def get_root(self):
    try:
    root = self.window.folders()[0]
    except IndexError:
    root = os.path.abspath(os.path.dirname(self.view.file_name()))
    return root

    Now, I don’t know Python but I’m familiar with the syntax and from what I can deduce self.window.folders() returns an array from which only the first element gets pulled out. I’m hoping that the qualified people viewing this comment will enlighten me and maybe we can do something about this.

    Anyway, thanks for this great tip, it really reduces the amount of clicks you have to perform to create a new file/folder.

  • http://twitter.com/jitendravyas Jitendra Vyas
    • clozed2u

      Great Solution for Windows User :)

  • http://www.tutosytips.com johanso

    works for me too., thanks once again!!!

  • Vishu

    Just updated Sublime Text 2 and couldn’t find the plugin via package install, version 2.0.1 Build 2217

    :(

  • matthewfordham

    Jeff,

    Hitting “escape” doesn’t turn on Vintage Command mode for me. It is definitly enabled though, as I see INSERT MODE it bottom left. Any ideas?

  • http://twitter.com/e11world Eddie11

    I’d love to know how you got the single/package file and loaded normalize in there? I can’t do that even though everything else worked out perfect.

  • Jon

    The sublime Advanced New File no longer works :(