[feature request] Move tab to beginning / end
-
I would like a way to quickly select a tab and move it to the end of the tabs list. The “end” (right end) of the tabs list is my “most recently used” and is where I’m working. I suppose for consistency there should be a “move tab to beginning”, but I’d never use it.
Extra points if I could CTRL-CLICK or SHIFT-CLICK to select multiple tabs and move those tabs to the end of the tabs list.
-
Interesting idea. While there are quite a few move-tab-around sequences, the “move to end” that you suggested does not exist, that I know of.
Unfortunately, while we here in the Community forum can say “that’s a good idea” or “here’s a workaround”, we cannot implement a feature request (see our FAQ). So if you want more than discussion and workarounds, you’ll have to make an official feature request in the right location.
As a potential workaround: if you move a tab from one View to the other and back, it will end up in the end position for the original view. So if you
- Macro > Start Recording
- View > Move/Clone Current Document > Move to Other View
- then View > Move/Clone Current Document > Move to Other View a second time
- Macro > Stop Recording
- Macro > Save Current Recorded Macro… and give it a name an memorable shortcut
Then from then on (even after Notepad++ restarts), using that macro or its shortcut will move the tab twice, which effectively puts it at the end of the current View’s tabbar.
It’s not ideal, since you will see it hop back and forth. And it definitely couldn’t handle your “extra points” for multiple at once. But if you’ve got dozens or hundreds of tabs, it might be easier than hitting
Ctrl+Shift+PgDown
dozens or hundreds of times, and might be faster than just holdingCtrl+Shift+PgDown
until it’s moved to the end.Alternately, assuming you are saving files as you edit them, you might be able to request Window > Sort By menu to add a “sort by file’s last-modified time” (with both oldest-to-newest and newest-to-oldest ordering). That’s a feature request they’re more likely to implement, because it goes nicely with other commands in the same menu. Those Sort By commands are available in shortcut mapper, so if you were to then assign a shortcut to the sort-by-last-modified-oldest-to-newest, then that one keystroke would put all of your tabs in last-modified order, without having to select multiple. (You could even argue for a similar pair that takes into account when it was last modified in Notepad++, even if the file hasn’t been saved yet; or have that instead of just using file time. But I don’t know if that would make it more or less likely to be implemented.)
-
Also, this is similar to the discussion on sort by access time. The MRU behavior described there might help you for your use-case as well.
-
Feature request made by @Blastocystis is here: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13982
-
I’ve needed this, too, but never bothered to script it before. Here are LuaScript functions for this, which don’t seem too difficult to port to other scripting plugins:
local function tabMoveHome() local index = npp:GetCurrentDocIndex(npp.CurrentView) for i = 1, index do npp:MenuCommand(IDM_VIEW_TAB_MOVEBACKWARD) -- 44099 end end local function tabMoveEnd() local index = npp:GetCurrentDocIndex(npp.CurrentView) -- +1 because CurrentView is 0 on the primary view and 1 on the second -- view, but PRIMARY_VIEW and SECOND_VIEW are 1 and 2 respectively local count = npp:GetNbOpenFiles(npp.CurrentView + 1) -- -1 because index is 0-indexed and count is (essentially) 1-indexed, -- another -1 for fence posts for i = index, count - 2 do npp:MenuCommand(IDM_VIEW_TAB_MOVEFORWARD) -- 44098 end end
(All code in this post is released under the WTFPL, do anything with it.)
This could be a slow operation if it has to move through a lot of tabs because the tab bar might need to be re-rendered every time.Selecting multiple tabs seems like a feature request with little other uses.
I suggest looking for a way to put such a command into the tab right-click menu so you can point, right-click and press the accelerator key with your other hand, which is a fast and solid-state gesture. Right-clicking a tab switches to it, which is moderately annoying.Alternatively, write an AHK script that detects shift-clicks over the tab bar (which is easy because the tab bars show up as controls, so you can probe the classname of the control under the mouse) and send the keybind to move to end.
And by write one, I mean use this because I went and did it anyway.; Hotkey is only active while any window of notepad++.exe is active #HotIf WinActive("ahk_exe notepad++.exe") ; ~ means don't sink input, + is shift. ; Can't run on mouse down because the next mouse up will select the ; tab that ended up under the cursor after the tab is moved to the end. ~+LButton Up:: { MouseGetPos ,,, &OutputVarControl ; ~= is match string against regex ; +^! are shift, ctrl and alt respectively if OutputVarControl ~= "SysTabControl" Send "+^!{PgDn}" } ; Remove the above restriction in case this script is incorporated into ; a larger script. #HotIf
-
@Saiapatsu said in [feature request] Move tab to beginning / end:
Here are LuaScript functions for this, which don’t seem too difficult to port to other scripting plugins
Indeed; here’s a PythonScript version:
# -*- coding: utf-8 -*- # references: # https://community.notepad-plus-plus.org/topic/24799 # for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript from Npp import * def get_number_of_tabs(view=None): retval = 0 if view is None: retval = len(notepad.getFiles()) else: for (pathname, buffer_id, index, v) in notepad.getFiles(): if v == view: retval += 1 return retval curr_view = notepad.getCurrentView() curr_doc_index = notepad.getCurrentDocIndex(curr_view) if 1: # move tab to end positions_to_move = get_number_of_tabs(curr_view) - curr_doc_index - 1 for __ in range(positions_to_move): notepad.menuCommand(MENUCOMMAND.VIEW_TAB_MOVEFORWARD) else: # move tab to beginning positions_to_move = curr_doc_index for __ in range(positions_to_move): notepad.menuCommand(MENUCOMMAND.VIEW_TAB_MOVEBACKWARD)
-