Skip to content

Commit 14b28ec

Browse files
committed
Update usage example
1 parent 9bbed7e commit 14b28ec

2 files changed

Lines changed: 37 additions & 28 deletions

File tree

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,43 @@ There are three main principles that the substitution follows:
4444
text.
4545

4646
2. When several patterns match, the shortest match is performed. For example,
47-
in ruby, the following switch is defined:
47+
in markdown, the following switch is defined:
4848

49-
``` ruby
50-
{ :foo => true }
51-
# switches into:
52-
{ foo: true }
49+
``` markdown
50+
- [ ] Implement true/false switching
51+
52+
switches into:
53+
54+
- [x] Implement true/false switching
5355
```
5456

55-
This works if the cursor is positioned somewhere on the ":foo =>" part, but
56-
if it's on top of "true", the abovementioned true -> false substitution will
57-
be performed instead. If you want to perform a "larger" substitution instead,
58-
you could move your cursor away from the "smaller" match. In this case,
59-
move the cursor away from the "true" keyword.
57+
This works if the cursor is positioned anywhere on the line except if it's
58+
on top of "true" or "false". In that case, the abovementioned true -> false
59+
substition will be performed instead. If you want to perform a "larger"
60+
substition instead, you could move your cursor away from the "smaller"
61+
match. In this case, move the cursor away from the "true" or "false" words.
6062

6163
3. When several patterns with the same size match, the order of the
6264
definitions is respected. For instance, in eruby, the following code can be
6365
transformed:
6466

6567
``` erb
6668
<% if foo? %>
69+
6770
could switch into:
71+
6872
<%# if foo? %>
73+
6974
but instead, it would switch into:
75+
7076
<% if true or (foo?) %>
7177
```
7278

7379
The second switch will be performed, simply because in the definition list,
7480
the pattern was placed at a higher spot. In this case, this seems to make
7581
sense to prioritize one over the other. If it's needed to prioritize in a
76-
different way, the definition list should be redefined by the user.
82+
different way (or simply to remove unneeded switches), the definition list
83+
should be redefined by the user.
7784

7885
## Advanced usage
7986

doc/switch.txt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,39 @@ There are three main principles that the substition follows:
8888
text.
8989

9090
2. When several patterns match, the shortest match is performed. For example,
91-
in ruby, the following switch is defined:
92-
91+
in markdown, the following switch is defined:
9392
>
94-
{ :foo => true }
95-
# switches into:
96-
{ foo: true }
97-
<
93+
- [ ] Implement true/false switching
9894
99-
This works if the cursor is positioned somewhere on the ":foo =>" part, but
100-
if it's on top of "true", the abovementioned true -> false substition will
101-
be performed instead. If you want to perform a "larger" substition instead,
102-
you could move your cursor away from the "smaller" match. In this case,
103-
move the cursor away from the "true" keyword.
95+
switches into:
96+
97+
- [x] Implement true/false switching
98+
<
99+
This works if the cursor is positioned anywhere on the line except if it's
100+
on top of "true" or "false". In that case, the abovementioned true -> false
101+
substition will be performed instead. If you want to perform a "larger"
102+
substition instead, you could move your cursor away from the "smaller"
103+
match. In this case, move the cursor away from the "true" or "false" words.
104104

105105
3. When several patterns with the same size match, the order of the
106106
definitions is respected. For instance, in eruby, the following code can be
107107
transformed:
108-
109108
>
110109
<% if foo? %>
111-
# could switch into:
110+
111+
could switch into:
112+
112113
<%# if foo? %>
113-
# but instead, it would switch into:
114+
115+
but instead, it would switch into:
116+
114117
<% if true or (foo?) %>
115118
<
116-
117119
The second switch will be performed, simply because in the definition list,
118120
the pattern was placed at a higher spot. In this case, this seems to make
119121
sense to prioritize one over the other. If it's needed to prioritize in a
120-
different way, the definition list should be redefined by the user -- see
121-
|switch-customization|.
122+
different way (or simply to remove unneeded switches), the definition list
123+
should be redefined by the user -- see |switch-customization|.
122124

123125
If you don't like the "smallest match" algorithm described on top, and you'd
124126
rather just attempt all matches in order, set the value of

0 commit comments

Comments
 (0)