1

I'm editing a small bash script:

d=$1
  year=$(date -d"$d" +%Y)
  month=$(date -d "$d" +%m)
  day=$(date -d "$d" +%d)
  hive -f /home/gavin_cameron/hive_queries/dc_player_daily_snapshot.hive -d jobYear="$year" -d jobMonth="$month" -d jobDay="$day" > logs/debug_$d.log 2>&1

I'd like to delete the 2 spaces for each line for year, month, day and hive.

When I place my cursor underneath the d in d=$1 and then press v and then press right once to cover the white space on the first line and then down to highlight all the white spaces, the entire lines are highlighted whereas I was expecting just the white space to be highlighted.

Why is that and how can I delete the indentation using visual mode plus delete in a oner rather than line by line deletion?

  • 2
    Close. Missed by a Ctrl. You're looking for Visual Block mode which is entered via Ctrl+V. This will confine the selection to a rectangle which you expand/contract with the directional keys. Press d when selection is what you want. – B Layer Jul 3 at 21:22
  • 1
    @BLayer You should add this as an answer! (don't use comments for answers...) – filbranden Jul 3 at 21:41
  • @filbranden I'm aware....but this has to be a duplicate, it's about rudimentary functionality. I'm not able to look right this sec, tho. – B Layer Jul 3 at 21:44
2

While you can use visual block mode via Ctrl-V, I would suggest a re-indenting tool (since that’s your goal).

Meet =. It’s an operator. It takes motions and text objects. And it indents things.

I would do =ip from anywhere in your block of code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.