Which keyboard shortcut will cut information to the clipboard? A practical guide for Ctrl+X / Cmd+X

Learn the universal shortcut to cut text to the clipboard (Ctrl+X on Windows, Cmd+X on macOS), with cross‑platform insights, code samples, and best practices for developers and power users.

Shortcuts Lib
Shortcuts Lib Team
·5 min read
Clipboard Shortcuts - Shortcuts Lib
Photo by Mariakrayvia Pixabay

Cut to clipboard: fundamentals and user workflows

Cutting to the clipboard is a core editing operation that accelerates text manipulation. When you select text and press Ctrl+X (Windows) or Cmd+X (macOS), the text is removed from the document and stored in the clipboard for immediate pasting elsewhere. This approach is foundational for refactoring documents, moving blocks of text between files, and quickly reordering content in code or prose. According to Shortcuts Lib, these shortcuts are nearly universal across editors, word processors, and many web apps, making them a predictable baseline for cross‑platform workflows. Below we show simple, working demonstrations and discuss how to adapt them to code editors and browser environments.

JavaScript
function cutSelection() { const sel = window.getSelection(); if (!sel.rangeCount) return; const text = sel.toString(); navigator.clipboard.writeText(text).then(() => { const range = sel.getRangeAt(0); range.deleteContents(); }).catch(err => { console.error('Clipboard write failed', err); }); }

This browser-based example copies the selected text to the clipboard and then deletes it from the page. It requires a secure context (HTTPS) and a user gesture to trigger. If you’re building a web app, wire cutSelection() to a toolbar button or a keyboard listener so users can perform cuts without leaving the flow of editing.

Python
# Python illustration: cut a slice from a string and copy to clipboard using pyperclip # Install: pip install pyperclip import pyperclip def cut_text(source, start, end): cut_piece = source[start:end] new_source = source[:start] + source[end:] pyperclip.copy(cut_piece) return new_source text = "The quick brown fox jumps over the lazy dog" new_text = cut_text(text, 4, 9) # cut 'quick' print(new_text) # The brown fox jumps over the lazy dog print(pyperclip.paste()) # quick

Python demonstrates the concept in a non-GUI context: you extract a substring, place it on the clipboard, and return the modified source. In production, you’d adapt this to your data model and UI, ensuring error handling around clipboard access. Shortcuts Lib emphasizes keeping UX predictable when mapping cut actions to custom controls.

Related Articles