Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New command: "Cut to New File" #108

Closed
nemoDreamer opened this issue Sep 24, 2014 · 12 comments
Closed

New command: "Cut to New File" #108

nemoDreamer opened this issue Sep 24, 2014 · 12 comments

Comments

@nemoDreamer
Copy link

I love the new "Copy Current File" command! That's why I'm suggesting a feature for this package that I haven't been able to find for a stand-alone package:

"Cut to New File"

  1. Select a block of text
  2. "ANF: Cut to New File"
  3. Enter filename
  4. Selected text is cut out of current file and pasted into new file.

Enhanced functionality

  • If new file already exists, append to it

Rationale

This is a workflow commonly used while refactoring monolithic files, to split modules, CSS groups, etc... into a more sensible folder/file hierarchy.

What do you think?

@skuroda
Copy link
Contributor

skuroda commented Sep 25, 2014

Good idea. Funny enough, I implemented something similar as a one off solution for someone before. I'll try to get this implemented soon!

@skuroda
Copy link
Contributor

skuroda commented Oct 21, 2014

@nemoDreamer, Sorry for taking so long on this. Been a bit busy lately. Got most of the functionality implemented last night, but hit an issue with multiple selections. Anyways, just wanted to give an update.

@nemoDreamer
Copy link
Author

BRILLIANT! The project I really needed this for got put on hold for a few weeks, so I'm fine!
Thank you for forging on! 👍

@skuroda
Copy link
Contributor

skuroda commented Oct 27, 2014

I've just pushed 1.4.0 which has this feature! Let me know how it works for you. The small thing I did, that I should have toggled was opening the specified file. If you find that bothersome, please let me know.

Thanks for using AdvancedNewFile!

@jpcirrus
Copy link

On OS X 10.9.5 and ST 2.0.2 I am getting the following traceback in the console on every invocation of this command:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 339, in run_
  File "./advanced_new_file/commands/cut_to_file.py", line 16, in run
Boost.Python.ArgumentError: Python argument types in
    View.add_regions(View, str, RegionSet)
did not match C++ signature:
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, int)
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)
    add_regions(SP<TextBufferView>, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::python::list, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, int)

@nemoDreamer
Copy link
Author

Thanks, @skuroda!
Sadly, I'm seeing the same error as @jpcirrus...
Should we be running a specific version of python? I've installed mine via homebrew:

$ python --version
> Python 2.7.8

Hm: I get the same error when I unlink my brewed version, to run OSX's Python 2.7.6

@jpcirrus
Copy link

@nemoDreamer Sublime uses a bundled Python which you can see the version of in the Sublime console. In my case with ST2 it is:

>>> import sys
>>> sys.version
'2.6.8 (unknown, Mar  9 2014, 22:16:00) \n[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]'

What Sublime version are you on?

@skuroda
Copy link
Contributor

skuroda commented Oct 30, 2014

Woops, looks like one of those undocumented API changes that happened between ST2 and ST3. I generally program for ST3, since that's what I use. But the plugin doesn't really utilize any new features, I'll keep in compatible with both versions. Will try to push a fix later today.

@skuroda
Copy link
Contributor

skuroda commented Oct 31, 2014

@nemoDreamer and @jpcirrus I've pushed a new version (1.4.1) that should fix the issue. Please let me know if you have any other issues!

@jpcirrus
Copy link

I confirm this is now working on ST2. Many thanks @skuroda

@nemoDreamer
Copy link
Author

Sorry for the delay: working for me too! And I like the fact that you open the new file: makes sense so you can add a header block, etc...

Thanks so much!
Where's the donation jar? 👍

@skuroda
Copy link
Contributor

skuroda commented Nov 7, 2014

Haha google? Just kidding, honestly I don't have anything set up to accept donations. Glad you enjoy the plugin!

@skuroda skuroda closed this as completed Nov 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants