{
  "$type": "site.standard.document",
  "description": "How I use Safari keyboard shortcuts and AppleScript Quick Actions to switch tabs and move the current tab left or right.",
  "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\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 accepts 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 assign 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\n * \"Select Next Tab\" to ctrl-l\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-05-30T00:00:00.000Z"
}