Sublime Forum

File Manager: An optimised package

#1

Hi!

I’ve been using SidebarEnhancement and AdvancedNewFile for a while now, but the first one is very very messy, there is options that aren’t needed (like the edit option), there is to option to create (new folder and new file), etc… In short, it’s not optimised, at least for me. AdvancedNewFile is a bit better, but, unfortunately, it does not touch to the side bar, and when you have to create a file with different folder in your folder, it’s left out.

So, I’ve created a plugin that has only the option that I need, so I can stay focus. Here’s a few things that it does:

  • create file like AdvancedNewFile, but can reference which folder create from (by default 0), like this: 2>a/relative/path (and it also works the other way around: -1>from/the/last/folder). You can change the symbol > in you settings.
  • It uses nice path: you can type ~/Pictures/ on window, and it will transform it C:\Users\<user>\Pictures\
  • It has a kind of a browser: when you want to create a file that already exists, it opens it for you, but when you want to create a folder that already exists, it opens a quick panel with all the file listed, with an option: create from here, which reopen the input panel from where you were
  • It has an auto completion! You can choose if you want to complete with files too, if you want files/folder first, etc.
  • You can hide options that are disabled with a settings (default to false)
  • compatible with ST2 (with a little code to paste in the console, I’ll give you this)
  • You can open a terminal from where you are or from the sidebar (specified the in the settings, if there is only one, it will open it directly, otherwise, it will show a quick panel to let you choose)

Create file from sublime text using File Manager

And, that’s it for the main options. Just try it out (disable SidebarEnhancement and AdvancedNewFile first), and tell me what you think about it. There’s probably few problems, this is why I don’t want to submit it too quickly, and I ask you to try so I can detect (and correct them) problems faster. But, it’s globally working (all the problem that I had are now solved), so you can use it. So, if you have any trouble, don’t hesitate to create an issue!

Installation

As I told you earlier, I haven’t submitted it to package control, but you can still use it to install FileManager.

  1. Bring up the command palette (ctrl+shift+p), and search for Package Control: Add Repository
  2. In the input that just appeared, just paste this: https://github.com/math2001/FileManager
  3. And then, just install a FileManager as you would normally do with an other package:
    1. Bring up the command palette (ctrl+shift+p), and search for Package Control: Install Package
    2. Search for FileManager and press enter

Little trick for Sublime Text 2 user

If you try to edit the settings, you’re going to see that in Preferences -> Package Settings that File Manager is disabled. Indeed, it’s using the command edit_settings, and it has only be introduced on sublime text 3. So, I’ve create a polyfill that works for ST2. All you have to do is:

  1. Copy the code that is highlighted on this gist
  2. Paste it in the sublime text console (View -> Show Console)

And check it out, it should work (give sublime text a restart if you have any trouble).

All it’s doing is this: it download the gist you copied the code from to your computer and save it here: $packages/User/settings.py

That’s it, there is more options, just have a look in the context menu, in the command palette, and in the settings!

And again, if you have any trouble, feel free to contact me, create issue, or letting me know which ever way you want!

Thanks for reading this long message.

Matt

PS: A tip for people working on web projects: in your .sublime-project file, add this:

"settings": {
    "url": "http://localhost/myProject" // whatever
}

And, now say you right click the file rootOfYourProject/about/index.html, it will open http://localhost/myProject/about/index.html :wink:

3 Likes

#2

I am really interested on this, if it is what I am thinking it is. It will autocomplete the files name when creating a new file/folder, then will it use the current files, folders names and the current autocompletion buffer to suggest the autocompletion?

Is it possible to use it at the same time as SidebarEnhancement and AdvancedNewFile?

Well, I am going to find out these questions soon.

0 Likes

#3

When you type img/fu and press tab, it will replace the fu by funny/ if you have this structure for example:

img/
|__funny/
   

It doesn’t use to autocompletion buffer, if I understand right what it is (a completion depending on the word you typed in previously in the input), but it’s easy to add (I prevent that behaviour by default).

That’s the good part: because it uses an API (input_for_path.py), it will also autocomplete when you duplicate, move etc!

I personaly don’t use File Manager and SE/ANF at the same time because you’re going to have duplicated commands.

Matt

0 Likes

#4

I was not thinking about it, I am think to autocomplete words from the current opened files.

I would like to know exactly what does this package has and the SidebarEnhancement and AdvancedNewFile does not has, and what does they had and this package has not.

For now I would like to keep both to be sure I am not losing any functionality. I would have to take some time to process exactly is going on here in. With this package I am interested on the autocompletion which seems to be promising.

I would just edit them, yours and the SidebarEnhancement and AdvancedNewFile packages and rename or remove duplicated menus entries. With this I want to not loose features.

My current SidebarEnhancement and AdvancedNewFile menus are edited. I am constantly improving them, so I could not just to throw my progress/working over them, uninstalling them and to go all over again adjusting this new package. I would prefer to know what does this package offers that they does not, so I could just to pick up what I need from this and keep my old stuff.

0 Likes

#5

You can just disable them, but still keep your changes:

  1. ctrl+shift+p
  2. package control: Disable Package
  3. SidebarEnhancement

You can enable it just by doing selecting Package Control: Enable Package

Hum, that’s going to be harder… So, I guess you’d only want completion from the strings of the current open files.

AdvancedNewFile has pretty much the same as File Manager except that you can define on the fly from where you want to create your file/folder. But the main advantage is that FM manage the side bar, which means that every feature/update is available every where.

SidebarEnhancement has more options, but I consider them useless (I’ve never used them), and it’s messy. So, I preferred to start from fresh that trying to tweak it.

So, try maybe for a day or two to disable both of them, and see what you would like to see in FM.

Are you @evandrocoan?

Matt

2 Likes

#6

It seems to be working already. Thank you for your efforts.

0 Likes

#7

Looks really nice!

But I seem to have a problem with for example creating a new file. My folder structure seems to cause FileManager to output this error:

Any ideas?

0 Likes

#8

from where do you run the command, the side bar or the shortcut?

Does it show the popup right away, are once you’ve typed the path or one you’ve pressed enter? (It should be right away)

Does it do this all the time (is it working some times? if yes, when)?

Can you copy the path, open up the console in sublime text and type:

import os.path;print(os.path.exists('<path>'));print(os.path.isdir('<path>')) Replace the <path> with your path.

You should see

True
True

Thanks for your time, I really appreciate that!

Matt

0 Likes

#9

@niklas, are you here?

0 Likes

#10

Sorry I will try to check tomorrow!

1 Like

#11

The correct path starts with \, but it seems Filemanger tries without?

import os.path;print(os.path.exists(r'\\gbw908.com\NOSLU$\Data\Python'));print(os.path.isdir(r'\\gbw908.com\NOSLU$\Data\Python'))
gives True True

import os.path;print(os.path.exists(r'gbw908.com\NOSLU$\Data\Python'));print(os.path.isdir(r'gbw908.com\NOSLU$\Data\Python'))
gives False False

Here is the console output

Traceback (most recent call last):
  File "C:\temp\Apps\Sublime Text 3 dev\sublime_plugin.py", line 780, in run_
    return self.run(**args)
  File "FileManager in C:\temp\Apps\Sublime Text 3 dev\Data\Installed Packages\FileManager.sublime-package", line 201, in run
  File "input_for_path in C:\temp\Apps\Sublime Text 3 dev\Data\Installed Packages\FileManager.sublime-package", line 52, in __init__
ValueError: The path create from does not exists ('gbw.blabla.com\\blabla$\\Data\\Python')

Not sure if it has to do with forward & backward slashes on windows? That is why I wrote an ‘r’ before the string to make it work

0 Likes

#12

I ask you a few question before, but you forgot to answer them.

  1. Does it show the popup right away, are once you’ve typed the path or one you’ve pressed enter? (It should be right away)
  2. Does it do this all the time (is it working some times? if yes, when)?
  3. from where do you create your file? (sidebar, shortcut, command palette…)
  4. Do you have some folders open?
  5. Do you have a file open?

Matt

0 Likes

#13

Sorry math! Here comes some clarifications!

Pop up shows right away, all the time.

I have a file open

Right click on the sidebar on a folder and choose new file

Once I remove file manager I can right click and create a new file on the sidebar

0 Likes

#14

So this is a path in a network share?

0 Likes

#15

That is correct!

0 Likes

#16

I don’t use this, so it’s going to be hard, but let’s try.

Can you install this https://github.com/math2001/FileManagerTests

Then, right click on this folder, and choose Test if this(ese) item(s) exists. (you can pick mutilple folders/files).

The console should open, tell me what you see. If everything was ok, you should see

| ------------------------------ | ------ | ------ |
|             Path               | Exists | Is dir |
| ------------------------------ | ------ | ------ |
| '<Path to your shared folder>' |  True  |  True  |

Some other questions :smiley:

  1. What version of sublime text are you using?
  2. Do you have git?

Thanks again for your time, I really appreciate it! :+1:

Matt

0 Likes

#17

I am using the latest sublime dev build, and not installed git currently :slightly_smiling:

Here is how it looks:

0 Likes

#18

I found the problem. (a function was removing the slash before in path_helper.py)

I pushed a commit that should solve the problem. Tell me if it works :slight_smile:

Matt

1 Like

#19

Awesome will check tomorrow!

0 Likes

#20

Works like a charm now! Thanks :slightly_smiling:

2 Likes