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

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

I tried hunting here and elsewhere on the Internet, but found nothing to help. If this is obvious or has been asked before, I am sorry.

I use Sublime Text 2, and I often get downloads of open files because they meet the criteria that I worked on.

I would like to list all these files from a new text file in a Sublime text.

Something like: for each open file write the file name (or, possibly, the full path to the file) Next

I know that I can get there from the open files panel, but these are just lists of files, there is no interaction with it, which does what I expected. To think, I can select files and use copy and paste to copy and copy.

Is this a built-in function that I missed? Is there any other package for this? Do I have to decide how to write a plugin for this?

Thanks again for any help on this.

(If that matters, it's Sublime text 2, mostly on Windows, but I also regularly switch to Mac for different tasks)

+4
source share
2 answers

Here's a hacky and relatively quick way to get something like this:

  • Ctrl + Shift + F (This brings up the Find in files dialog)
  • Make sure Regex mode is on (button .* ) And search after $ , for example
  • Now you have a large file with all the contents. Hope is not too great to slow down the hill. Now press Ctrl + F for the normal Search dialog
  • Type ^_ (carriage + space, not underscore) and click Find All
  • Ctrl + Shift + K to delete all content lines

There! Now you have a list of all open files with the full path.

More concise:

  • Ctrl + Shift + F Button
  • .* enabled, search after $
  • Ctrl + F
  • .* button remains, search after ^[space]Find All
  • Ctrl + Shift + K

Another way is to make yourself a small plugin to do this for you with a keystroke.

From the SublimeText2 API you can get useful methods:

 Class sublime.Window.views() [View] Returns all open views in the window. 

Then

 Class sublime.View.file_name() String The full name file the file associated with the buffer, or None if it doesn't exist on disk. 

You can start with an existing plugin. However, this is due to some Python programming skills.

0
source
 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()])) 
  • Create a file with the above code and save it as filelist.py
  • Open sublime, Goto Preferences -> Select Browse Pacakages
  • Go to user folder and move over file ( filelist.py )
  • Now go to settings -> Keybinding
  • Add below:

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

  • Now press f12, you got your path of open files in a new window

thanks

0
source

All Articles