vim - how to select multiple lines?


April 2019


6 time


Say I have this text:

# Get host
db_host=$(echo "dbhost") 
# Get DB name
db_name=$(echo "dbname")
# Get user
db_user=$(echo "dbuser")
# Get password
db_pass=$(echo "dbpass")

and I want to select every variable name and produce this output below the text:

echo "db_host: $db_host"
echo "db_name: $db_name"
echo "db_user: $db_user"
echo "db_pass: $db_pass"

On sublime for example I'd highlight =$( and hit +d multiple times, go back to the start of the line, copy with SHIFT+, go to the last line and create a new one, paste, highlight all new lines, hit +SHIFT+l and then add whatever I want.

I'm using vim multiple cursors but I'm not sure this is the way to go. Any directions?

0 answers