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
Open files in same tab or in a new split #81
Comments
|
This should be possible. Notice that the fuzzy finder view supports splitting commands. So, if you execute @paulcsmith @admpsktt Does that help? |
@izuzak Thank you! This worked brilliantly! For others that want this behavior here are my keybindings
|
The only thing missing is opening a file in the same tab. I don't see commands for that :S |
|
Thanks @paulcsmith. That works. Any news on opening the file in the current tab? |
+1 for a shortcut to open files in the current tab |
+1 |
2 similar comments
+1 |
+1 |
+1 |
1 similar comment
|
|
Also |
+1 |
+1 |
Opening a file from fuzzy-finder into the current selected tab would be awesome! After a day of work i'm left with 40++ tabs to close because I use the fuzzy-finder to navigate files. Atom fixed this with the tree-view, now its time to fix this for Fuzzy-Finder, no? |
+1 |
2 similar comments
+1 |
+1 |
+1 |
I have the tabs plugin turned off any only use fuzzy finder to move between files. Tabs still build up in the background and eventually make atom unbearably slow. This feature would greatly improve my workflow. |
To replace tabs from the fuzzy finder menu I've come up with this: in your init.coffe file atom.commands.add '.fuzzy-finder atom-text-editor[mini]', 'custom:replace-tab', ->
atom.workspace.getActiveTextEditor().destroy()
atom.commands.dispatch(@, "core:confirm")
In your keymap file:
It's not ideal but seems to do the trick. And gave me a chance to mess around with the init file. :) Edit: Needs some work on splitted panels. i guess might have a look at it later on. |
The above solution is pretty cool, but needs some tweaking.
Can work around, but a proper replace solution is still needed. Destroy and new isn't really ideal. Nice work figuring this out though! |
I made a small tweak to @lewis-fidlers solution. This is pretty close to the behavior I expect in Vim: If the current file is not saved, then open the searched file in a vertical split. Otherwise, close the current file and 'replace it' with the new searched file. atom.commands.add '.fuzzy-finder atom-text-editor[mini]', 'custom:replace-tab', ->
# you want to open in an empty pane
if typeof atom.workspace.getActivePaneItem() is "undefined"
atom.commands.dispatch(@, "core:confirm")
# current file is saved
else if ! atom.workspace.getActivePaneItem().isModified()
current = atom.workspace.getActivePaneItem()
atom.commands.dispatch(@, "core:confirm")
current.destroy()
# current file is not saved
else
atom.commands.dispatch(@, "pane:split-right") The order of splitting and destroying is kind of weird, but it is the way it is because I was experiencing some weird behavior if I tried to destroy the current pane before opening the new one (I tried core:confirm and pane:split-*, but had weird behavior with both). I set my keybinding to overwrite the default enter key: '.fuzzy-finder atom-text-editor[mini]':
'enter': 'custom:replace-tab' Finally working the way I like! EDIT: |
+1 from anybody coming from Emacs, where there are no tabs and you just switch buffers all day with a finder |
This works great with a single file inside the tab. When I've made a split (let's say, one file on the left and one on the right, and I'm currently in the right file), both yours and @lewis-fidlers's solution will close the right split, then open the chosen file in a new tab instead of replacing that split. Maybe this needs to be updated for newer Atom versions? I'm not familiar enough right now. |
While @lewis-fidlers and @roerjo solutions work well enough, it did feel hacky to constantly destroy pane items. I found that Atom does natively support opening in the sane pane item with a pending pane item (thanks to @eonist for the tree-view tip). Here's the function (which shouldn't have any split pane issues): atom.commands.add '.fuzzy-finder atom-text-editor[mini]', 'me:replace-pane-item', ->
paneItem = atom.workspace.getActivePaneItem()
# Dispatch with default opening if there are unsaved changes. Do _not_ clobber unsaved changes.
if paneItem.isModified and paneItem.isModified()
atom.commands.dispatch(@, "core:confirm")
else
# Need to set current pane item to pending in order for Workspace#open to work as expected.
# I do not use pending pane items for anything else so do not restore original pending item
atom.workspace.getActivePane().setPendingItem(paneItem)
selectedUri = atom.packages.getActivePackage('fuzzy-finder').mainModule.projectView.selectListView.getSelectedItem().uri
# Open with pending to open file in same pane item - https://atom.io/docs/api/v1.38.2/Workspace#instance-open
atom.workspace.open(selectedUri, {pending: true, searchAllPanes: atom.config.get('fuzzy-finder.searchAllPanes')}).then (editor) ->
# Disable pending on new editor to avoid unexpected behavior e.g. future file openings replacing current pane item
editor.terminatePendingState() I'll be making any future tweaks to this command in my atomfiles. I have the command mapped to Next on my vim/emacs-like wishlist is for the buffer finder to list and autocomplete all files that have been opened, not just current open pane items. If anyone has any tips I'm all ears |
I did find the recent-files-fuzzy-finder package achieves vim-like navigation to previously opened buffers. Here are my two commands which achieve opening in place for files and previous buffers, along with their keybindings |
paulcsmith commentedMar 6, 2015
Similar to Ctrl-p in vim
I often want to replace the current tab with a new file instead of opening in a new tab, then navigating back to the old tab and closing it.
It would also be really nice to hit
<Ctrl-v>
in fuzzy finder to open the file in a new vertical split and<Ctrl-S>
for a horizontal split.The text was updated successfully, but these errors were encountered: