Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a text list of open files in Sublime Text 2

Hi there and thanks in advance for any help on this.

I have tried hunting here and other places on the web but have not found anything to help. If this is obvious or has been asked before then I am sorry.

I am using Sublime Text 2 and I often end up with a load of open files because they meet a criteria that I have been working on.

I would like to list all those files out a new text file, within Sublime text.

Something like: for each open file write filename (or possibly full filepath) Next

I know I can get there from the open files panel but that only lists the files, there is no interaction with it that does what I expected. To thought I might be able to highlight files and use copy and paste to get a list.

Is this a built-in function that I have missed? Is there already a package to do this? Will I have to work out how to write a plug-in to do this?

Once again, many thanks for any and all assistance on this.

(If it makes any difference this is Sublime text 2, mostly on Windows but I do also switch across to Mac regularly for different jobs)

like image 330
megapode Avatar asked Mar 06 '13 11:03

megapode


1 Answers

import sublime
import sublime_plugin


class RunningfileCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.window().new_file().insert(edit, 0, "\n".join([view.file_name() for view in sublime.active_window().views() if view and view.file_name()]))
  1. Create file with above code and saved as filelist.py
  2. Open sublime, Goto Preferences -> Select Browse Pacakages
  3. Goto User folder and move above file(filelist.py)
  4. Now goto Preferences -> Keybinding
  5. Add below content on it:

    [{ "keys": ["f12"], "command": "runningfile" }]

  6. Now press f12, you got your all opened files path in new window

Thanks

like image 136
Hiren Raiyani Avatar answered Oct 21 '22 00:10

Hiren Raiyani