{
  "$type": "site.standard.document",
  "description": "The Safari keyboard shortcuts I use to switch tabs and move the current tab left or right with AppleScript Quick Actions.",
  "path": "/moving-safari-tabs-with-keyboard-shortcuts/",
  "publishedAt": "2024-04-03T00:33:00.000Z",
  "site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
  "tags": [
    "AppleScript Tools"
  ],
  "textContent": "For years, I have F2 and F3 in vim set to move the current tab left and right respectively — I wrote about navigating tabs with the keyboard in MacVim previously. I wanted to do the same in Safari. I found a way to do it with AppleScript.\n\nThe short answer: Safari already has built-in shortcuts for switching tabs, and macOS lets me remap those menu commands. Moving the current Safari tab left or right takes a small AppleScript Quick Action.\n\nThe built-in Safari shortcuts are:\n\n * ctrl-tab or shift-cmd-] — select the next tab\n * ctrl-shift-tab or shift-cmd-[ — select the previous tab\n\nI prefer ctrl-h and ctrl-l because they match how I move between tabs in tmux and other tools. The rest of this post is how I set that up, plus cmd-F2 and cmd-F3 for moving the current Safari tab left and right.\n\nSave this as a Quick Action \"Move Current Safari Tab Left.workflow\" as a Run AppleScript action:\n\n--Move left\ntell application \"Safari\"\n\tset currentTabIndex to index of current tab of front window\n\tset totalTabs to count of tabs of front window\n\t-- Ensure there is a previous tab to swap with\n\tif currentTabIndex > 1 then\n\t\tset previousTabIndex to currentTabIndex - 1\n\t\t-- Swap the tabs\n\t\ttell front window\n\t\t\tset currentTab to tab currentTabIndex\n\t\t\tset previousTab to tab previousTabIndex\n\t\t\tmove previousTab to after currentTab\n\t\tend tell\n\tend if\nend tell\n\nSave this as a Quick Action \"Move Current Safari Tab Right.workflow\" as a Run AppleScript action:\n\n--Move right\ntell application \"Safari\"\n\tset currentTabIndex to index of current tab of front window\n\tset totalTabs to count of tabs of front window\n\t-- Ensure there is a next tab to swap with\n\tif currentTabIndex < totalTabs then\n\t\tset nextTabIndex to currentTabIndex + 1\n\t\t-- Swap the tabs\n\t\ttell front window\n\t\t\tset currentTab to tab currentTabIndex\n\t\t\tset nextTab to tab nextTabIndex\n\t\t\tmove nextTab to before currentTab\n\t\tend tell\n\tend if\nend tell\n\nThe workflows accept no input in Safari.app.\n\nThen, under the Settings.app > Keyboard > Keyboard Shortcuts > App Shortcuts, assign these 2 to Safari.app:\n\n * \"Move Current Safari Tab Left\" to cmd+F2\n * \"Move Current Safari Tab Right\" to cmd+F3\n\n(I didn't use F2 and F3 because I have assigned them to do other things in Safari)\n\nCouple them with assigning these to All Applications too:\n\n * \"Select Previous Tab\" to ctrl-h — switch to the previous Safari tab\n * \"Select Next Tab\" to ctrl-l — switch to the next Safari tab\n\nThese 4 keyboard shortcuts make moving around and re-ordering tabs in Safari so much easier.",
  "title": "Moving Safari Tabs with Keyboard Shortcuts",
  "updatedAt": "2026-06-13T00:00:00.000Z"
}