SublimeText3 open header/source - sublimetext2

I use sublimetext3 to program C++.
I use multiple window splits with multiple files open.
Sometimes I use alt+o hotkey / switch_file command to open the associated header/source file.
If I hit switch_file command and the matching header/source is already open in the same sub window split, it will jump to that tab instead of reopening the file.
But if I have a header open in one sub window split, and the source open in another sub window split, and I do switch_file command, it will open another copy of the file in the currently focused window.
Is there a way that I can set it to jump to the file even if it needs to focus another window split?
Thanks

I think the easiest way to establish this is to change the switch_file command.
Install PackageResourceViewer and type PackageResourceViewer: Open Resource, select Default and then open switch_file.
In line 41 just change
self.window.open_file(new_path, flags = sublime.FORCE_GROUP)
to
self.window.open_file(new_path)
and save the file. This will not overwrite the existing file (which is in a zip folder), but create a file, which shadows the original file.

Related

Is there a way to open a file in split view from recent files popup

I have this Recent files popup:
I can open any file from it by pressing ENTER. Is there any way to open the file in a split view? I have tab limit set to 1, so opening a file from Recent files and then opening it in a split view replaces the currently open file. I'd like to open a file in a split view without replacing the current tab. Maybe key mapping somehow?
Unfortunately not (as far as my knowledge goes).
https://youtrack.jetbrains.com/issue/IDEA-108556 -- watch this and related tickets (star/vote/comment) to get notified on any progress.
The only other possible options (generally speaking):
Shift + Enter to open it in a new/detached editor.
Open as usual and then use Move Down or Move Right to move it in that split group (will create if you do not have one). But this will NOT work if you set to have only 1 editor tab max.
Open as usual, clone it to bottom/right side (so it opens in both splitters) and then re-open recently closed file in one of the split areas again (yeah .. long and inconvenient).
Move focus to another splitter before invoking Recent Files (if you have no such splitter yet -- create one for current file). Now chose file as usual -- it will replace file in current splitter (inconvenient as you need to think about correct location in advance instead of quickly opening the needed file).

How do I configure fpp (Facebook Path Picker) to open new tabs in macvim using a vimer alias?

I believe that I need to set the $FPP_EDITOR environment variable to be able to change the default editor that fpp would invoke when opening files.
I have aliased mvim to vimer -t with alias mvim="vimer -t". This means that the mvim command should open new files in the currently available (operating system level) macvim window, and even if a sequence of files is included, it should open them in new tabs in that (operating system level) window. So if I already have an instance of macvim running and I try to pass in 4 files, I now have one window with 5 tabs in it.
But when I try to use mvim as the editor (with export FPP_EDITOR="mvim"), it opens the files in new macvim (operating system level) window, in separate (vim buffer level) windows in a single tab. So if I already have an instance of macvim running and I try to pass in 4 files, I now have two macvim "instances" running in separate OS-level windows, one with 1 tab with 1 buffer-level window, and one with 1 tab with 4 buffer-level windows.
It seems like FPP must be doing more than just passing in files in a sequence as a suffix to the $FPP_EDITOR command. I'm not sure what that is, nor exactly how to figure it out.
This is an answer to the question (technically) that I figured out as I was writing out the question.
But, it's missing all the right extra info about what was going wrong, so I'm going to this as an answer, but will happily accept another answer that can do more than just answer the question per se, but can give some background info about why the aliasing only sorta works.
The key though (if you just want a solution) is to use
export FPP_EDITOR="vimer -t"
and this performs as desired. For some reason it does not seem that setting the environment variable to a command that is aliased uses the aliased command, if it has an available original meaning (which mvim does).

Atom setting to open files in the same window?

I'm just trying out Atom for the first time and I find it bothersome that Atom keeps opening a new window for each file I click on - I'd prefer that it defaulted to opening each file in the same window.
I'm hoping for something along the lines of "open_files_in_new_window" : false, in Sublime. Unfortunately, all the google results I'm seeing just lament that this toggle is not immediately obvious.
In your terminal you can type atom -a <filename||folder> and the file(s) will open within the same atom window.
Go to Settings > Packages, look for the tabs package. In the settings for this package, choose "use preview Tabs".
Per the atom -h command, one should open files with -n=false or --new-window=false argument passed so that they are opened in an existing window, e.g.
atom -n=false ~/Desktop/test.py
One could make atom -n=false an alias of atom in the ~/.bashrc or ~/.zshrc file, or one could edit the corresponding file in /home/<your username>/.local/share/applications so that the command it invokes is, for instance, /usr/lib/atom/atom -n=false %F.
Just in the editor window, drag the open tab by mouse onto the window you need.

How to open and save files

Is there a way to quickly open files in sublime text2?
At the moment I open files like this.
I open my terminal and enter
subl source/myproj/myfile.rs
Can I do this inside of sublime text2/3?
Also when I want to create a new file in source/myproj/ I usally press ctrl + n to create a new window and then I hit ctrl + s to save and name the file. The problem is when I hit ctrl + s my file system dialog opens and I have to use my mouse.
I think I saw someone using vim and he just could say source/myproj/mynewfile.rs and then the file would be created.
Is this possible in sublime text 2/3?
To quickly open a file in your current project, you can hit Ctrl+P and start writing the filename. This will sort through the files in your project and give you a little list, most likely the one you are looking for is pre selected, but if not, it is somewhere near the topmost options to select from, use arrow key down and highlight it, press enter and you just opened that file.
Another option to quickly create a file is using the AdvancedNewFile plugin.
When you hit Ctrl+n, it asks near the bottom of the window for a path and filename, once you enter it, it opens the new tab with the file already created, not an untitled file to later use system dialog to save to disk.

start opened file from sublimetext in associated program

i usually edit files in sublime text 2 that can also be edited and compiled with another program. As i have them already opened in sublimetext i do the following:
right click and choose "copy file path" (to clipboard)
Win+R to open windows run dialog
CTRL+V to paste the file path
hit enter to open the file with the associated program
i wonder some shortcut can be configured so it automatically starts the opened file with its associate program
thanks in advance
This can be done. I was in a very similar situation using Sublime as my editor of choice over the default SAS program editor. I was able to use the win32com.client.dynamic.Dispatch module to connect to SAS via OLE and pass text from Sublime directly to SAS using Sublime's build system to call my plugin. Making the connection was the easy part, it was the other processing that I had to do which was the time consuming part, but since you want to pass just a file name or the entire contents of your file, this should be a fairly straightforward plugin. Since I do not know what program you wish to open, here is the code that makes my implementation work. Maybe you caan glean something out of this.
def send_to_sas_via_ole(selected_code):
from win32com.client.dynamic import Dispatch
sasinstance = Dispatch("SAS.Application")
# submit the lines to sas
for selection in selected_code:
# for some reason cannot send as one big line to SAS, so split into
# multipe lines and send line by line
for line in selection.splitlines():
sasinstance.Submit(line)
and then the call in the run method of my plugin class:
class RunSasMakoCommand(sublime_plugin.TextCommand):
def run(self, edit):
try:
send_to_sas_via_ole(selected_code)
except Exception as e:
print "\n".join(selected_code)
print "Couldn't connect to SAS OLE"
print e
Good luck!
Open 'regedit.exe';
Navigate to
HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command
correct the path. Exit 'regedit.exe'
(optional) restart 'explorer.exe' or reboot your PC.
enjoy :p;
Right click on the file, press "Properties". You will see Opens with SomeProgram and then a change button. Click on the change button, and then look through the list for Sublime Text, if you can't find it, you can choose an application using the file explorer, from there you can navigate to C:\Program Files\Sublime Text 2 and choose sublime_text.exe