2

A lot of times I want to copy some error message and paste it into some web form indented by 2 or 4 spaces. Is there a quick way to modify the contents of my copy-paste buffer to add an N-space indent?

Currently I open vim, paste into vim, indent, copy back out of vim, paste into the destination, then close vim.

1
  • 1
    I was about to suggest what you're already doing. Creating a script is probably the next step. Just use sed or perl to s/^/ /g and a script to paste from clipboard, call sed, copy to clipboard.
    – Alex
    Aug 7, 2015 at 18:22

1 Answer 1

0

I came up with this one-liner using xsel to indent the clipboard by 2 spaces:

$ xsel -b | sed -e's/^/  /' | xsel -b --input

You can replace the " " in the sed expression with whatever number of spaces/tabs or other prefix you want.

You must log in to answer this question.

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