2

Usually in Terminal to delete text you have to sit there for an hour holding the ⌫ Delete. This is particularly annoying since I use vim in the terminal for Text file editing.

Mac Terminal Text deletion

But anywhere else in OS X or any computer since 1988 really you can just select text and delete. Not in terminal.

I know terminal isn’t meant to be the latest in computing, but batch deletion of text is really essential. How do I fix this? Also, yes, I know about ⌥ Option⌫ Delete to delete full words. Still it's no bueno for text editing.

How can I delete whole lines of selected text?

1 Answer 1

3

You need to learn the keyboard commands for the editor you are using; in this case, vim.

To delete, press Esc for "Command Mode" then....

  • x - for a character
  • dw - for the current word
  • dd - for the current line
  • 5dd - for five lines

Terminal isn't a GUI environment so mouse interaction is minimal. See Vim Help Files for full documentation on how to use Vim.

(I personally prefer nano as it's much more user friendly and included with macOS)

6
  • 1
    Okay thanks buddy. I was hoping there was a Terminal-wide way to do this, but I kind of doubt it. Like when I select text in MacVim, I can delete selected text, but as soon as I open the same Vim in terminal, I can’t, just because of how Terminal is. I run R code in Terminal a lot and a lot of times there’s crap I have to edit early in the line. I use Sublime Text (trying to move to VIM) as a DIY IDE, so it’s not that bad, but it would really be nice if Apple upgraded some of their Terminal features for the new millennium lol. I mean at least give me some features from the 90’s lol.
    – Chris
    May 19, 2018 at 2:05
  • Also, vim is included with macOS too. And yes, I know Terminal isn’t a GUI, but I select text often using the shift key, then delete. But thanks for those commands. Trying to get used to vim, although I love it so far.
    – Chris
    May 19, 2018 at 2:17
  • 1
    but it would really be nice if Apple upgraded some of their Terminal features for the new millennium lol. It's not an Apple thing...Apple's Terminal is a terminal window or shell into the OS. Every OS (macOS, BSD, Linux and even Windows) has a command line interface like this. It a CLI and you're asking it to have GUI functionality; it just can't because it isn't.
    – Allan
    May 19, 2018 at 5:48
  • Yea, i guess that’s a valid point. But I do some programming and i use Sublime Text + an add-on called “SendText” that sends text to the terminal. So you write your code in Sublime, then send it over to Terminal. It would be nice if I could edit my code directly in Terminal and get rid of that extra app, but it’s just too cumbersome to edit text in it. And the reason for making this post is that I’m trying to transition from Sublime to vim, and I’ve been doing it by opening 2 terminal windows side by side but the inability to select text is rough. Although the commands he posted are helpful
    – Chris
    May 20, 2018 at 15:08
  • But the more I think about it, I somewhat disagree and I’ll tell you why. Terminal is a Terminal Emulator, not a Terminal. Like if we were running on an Apple 2 or VT320, yes, it literally couldn’t. But it’s an emulator. There’s no reason they couldn’t add some GUI functionality such as “select” to provide flexibility. Of course Terminal should be primarily a Keyboard driven environment, but there’s no reason to add flexibility if you want to use a mouse every so often. But I’m gonna try gvim (MacVim) for now which has some GUI functionality (although it has some others issues for my workflow)
    – Chris
    May 20, 2018 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .