2017/06/23

Tricks share: Edit multiple places at the same time on atom

About

As a developer, editors are one of tools I need to deal with all the time. Here are tricks I used on improving the typing experiences in atom

Trick 1: Edit multiple words at the same time

Given text below
Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |  12   |  5  |  7    |
    |  12   |  10 |  2   |
    |  20   |  5  |  15  |
Suppose you need to fix the numbers in start column to be 30
Double click those number with Left Ctrl pressed.
Type 30 to change all of highlighted words

Trick 2: Shortcut on changing identical words

Given text below
Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |  30   |  5   |  7    |
    |  30   |  10 |  2   |
    |  30   |  5   |  15  |
Suppose you would like to change cucumbers as oranges. Beside using replacement from Ctrl f, you can use Ctrl D selection.
Click cucumbers and press Ctrl D 3 times as there are 3 cucumbers.
Then, type oranges which changes all the highlighted words.

Trick 4: Edit rows at the same time

Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |  30   |  5  |  7   |
    |  30   |  10 |  2   |
    |  30   |  5  |  15  |
Suppose you would like add a column country with all same value Hong Kong.
Add a column country manually
Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | country | start | eat | left |
    |  30   |  5  |  7   |
    |  30   |  10 |  2   |
    |  30   |  5  |  15  |
Select rest of lines with left click while pressing Left Ctrl.
Type | Hong Kong for adding such value to highlighted columns
Fix the spacing in the headers by pressing spaces
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers

  Examples:
    | country   | start | eat | left |
    | Hong Kong |  30   |  5  |  7   |
    | Hong Kong |  30   |  10 |  2   |
    | Hong Kong |  30   |  5  |  15  |

Round up…

Tricks for editing things at the same time are very common on coding. Let me know if you have any more tricks about that :D

沒有留言:

張貼留言