You can cut and paste text through the killing and yanking features provided by the bash shell.

Killing Text Forward

We can use Ctrl K to cut the text behind the cursor:

1
Ctrl + K    # press Control and K keys
img

before killing

img

after killing

Killing Text Backward

We can use Ctrl U to cut the text before the cursor:

1
Ctrl + U    # press Control and K keys
img

before killing

img

after killing

Killing Word Forward

We can use Alt D to cut the word on or after the cursor:

1
Alt + D    # press Alternate and D keys
img

before killing

img

after killing

Killing Word Backward

We can use Ctrl W or Alt Backspace to cut the word before the cursor:

1
Ctrl + W    # press Control and W keys

Or:

1
Alt + Backspace    # press Alternate and Backspace keys
img

before killing

img

after killing

Yanking (Pull word or text back from the Kill Ring)

We can use Ctrl Y to pull the killed word or text back from the kill ring.

We use either of the kill commands to demonstrate:

1
Ctrl + W    # press Control and W keys
img

before killing

img

after killing

We run the following command to pull killed word back:

1
Ctrl + Y    # press Control and Y keys
img

after yanking

References 8.4.4 Killing And Yanking

Buy me a coffeeBuy me a coffee