Open paulcsmith opened 9 years ago
:+1:
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.
This should be possible. Notice that the fuzzy finder view supports splitting commands. So, if you execute pane:split-right
while a specific file is selected in the fuzzy finder -- that file will be opened in a split view. The only thing left to do is that you customize your keybindings so that it triggers pane:split-right
when you hit <Ctrl-v>
(see this). By default, that command triggers on cmd-k right
(on OSX), see this.
@paulcsmith @admpsktt Does that help?
@izuzak Thank you! This worked brilliantly!
For others that want this behavior here are my keybindings
'.fuzzy-finder atom-text-editor[mini]':
'ctrl-v': 'pane:split-right'
'ctrl-s': 'pane:split-down'
The only thing missing is opening a file in the same tab. I don't see commands for that :S
:heart:
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
+1
+1
+1
:+1:
:+1: this would greatly reduce the clutter in my workspace :heart_eyes_cat:
Also :+1:ing this, holding shift-cmd-t or something like that replace a current buffer/tab with the new file would be awesome.
+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
+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:
'.fuzzy-finder atom-text-editor[mini]':
'ctrl-v': 'pane:split-right'
'ctrl-s': 'pane:split-down'
'alt-enter': 'custom:replace-tab'
alt-enter
will now close the tab you are in and open the one selected in the fuzzy finder.
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: This method does seem to break if you only single click an item on the Project panel and attempt to perform a search from that 'preview' file.
+1 from anybody coming from Emacs, where there are no tabs and you just switch buffers all day with a finder
@roerjo
I made a small tweak to @lewis-fidlers solution. This is pretty close to the behavior I expect in Vim:
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 cmd-enter
so I can choose when to replace a pane item.
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
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.