Skip to content

Commit 6b6cfda

Browse files
committed
Try to implement full ruby string switching with quotes
1 parent a3fd7bf commit 6b6cfda

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

ftplugin/ruby/switch.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ let b:switch_definitions =
1717
\ g:switch_builtins.rspec_expect,
1818
\ g:switch_builtins.rspec_to,
1919
\ g:switch_builtins.rspec_be_truthy_falsey,
20+
\ g:switch_builtins.ruby_keyword_string,
2021
\ g:switch_builtins.ruby_string,
2122
\ g:switch_builtins.ruby_short_blocks,
2223
\ g:switch_builtins.ruby_array_shorthand,

plugin/switch.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ let g:switch_builtins =
5252
\ 'if false and (\(.*\))': 'if \1',
5353
\ 'if \%(true\|false\)\@!\(.*\)': 'if true or (\1)',
5454
\ },
55-
\ 'ruby_string': {
55+
\ 'ruby_keyword_string': {
5656
\ '"\(\k\+\%([?!]\)\=\)"': '''\1''',
5757
\ '''\(\k\+\%([?!]\)\=\)''': ':\1',
5858
\ ':\(\k\+\%([?!]\)\=\)\@>\%(\s*=>\)\@!': '"\1"\2',
5959
\ },
60+
\ 'ruby_string': {
61+
\ '"\(\%([^"\\]\|\\.\)*\)"': '''\1''',
62+
\ '''\(\%([^''\\]\|\\.\)*\)''': '"\1"',
63+
\ },
6064
\ 'ruby_short_blocks': {
6165
\ '\(\k\+\)(&:\(\k\+[!?]\=\))': '\1 { |x| x\.\2 }',
6266
\ '\(\k\+\)\s\={\s*|\(\k\+\)|\s*\2.\(\S\+\)\s*}': '\1(&:\3)',

0 commit comments

Comments
 (0)