VS代码选择引号之间的文本
我有一个像下面的庞大数组列表
$data= [
'user_name' => 's',
'user_place' => 'a',
'address_list_code' => 's',
'block_number' => 3,
];
,因此我想用所有大写替换键字符串。我知道使用VS代码快捷方式将选定的文本转换为大写ctl+alt+alt+alt+alt+u
,并且它起作用。 但是我只想在单个报价之间选择所有键,然后使其大写,所以预期的输出是
[
'USER_NAME' => 's',
'USER_PLACE' => 'a',
'ADDRESS_LIST_CODE' => 's',
'BLOCK_NUMBER' => 3,
];
我尝试了此扩展名,但也没有吸取单个引号之间的所有文本
I have a vast array list like below
$data= [
'user_name' => 's',
'user_place' => 'a',
'address_list_code' => 's',
'block_number' => 3,
];
so I want to replace the key string with all uppercase.I know to convert selected text to uppercase using vs code shortcut Ctl+Alt+u
and it works.
But I want to select only all keys in between a single quote and make it uppercase so the expected output is
[
'USER_NAME' => 's',
'USER_PLACE' => 'a',
'ADDRESS_LIST_CODE' => 's',
'BLOCK_NUMBER' => 3,
];
Even I tried this extension but not suceded to select all text in between single quotes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(4)
查看此小提琴: https://jsfiddle.net/m82ycfxw/m82ycfxw/
我制作了一个普通的JS代码,将所需的文本转换为上情况。
这可能是暂时的事情,但我希望这对您有用。
只需更改
str
变量即可。将所有完整的数据对象放入Backticks(````)中,然后运行代码。Check out this fiddle : https://jsfiddle.net/m82ycfxw/
I made a normal JS code to convert the desired text to upper case.
This might be a temporary thing but I hope this will work for you.
Just change the
str
variable. Put all your complete data object inside backticks (` `)and run the code.扩展名 select 可以帮助您。
'
'
ESC
退出多光标The extension Select By could help.
'
'
Esc
to exit multi Cursor当然,您可以本地进行此操作:
settings.json
中,暂时删除_
作为单词分隔符(例如“ editor.wordseparator”:“!@#$ $ %^&*() - =+[{]} \\ |;:'\“,。
。
展开选择
。由于您将_
作为单词定界符关闭,因此将扩展以填充引号。否则,所有的键都需要具有相同数量的单词才能使此工作起作用。上情况
。设置中。
Sure, you can do this natively:
settings.json
, temporarily remove_
as a word separators (e.g."editor.wordSeparators": "!@#$%^&*()-=+[{]}\\|;:'\",.<>/?,
) (Notice no_
).
expand selection
. Since you turned off_
as a word delimiter, this will expand to fill the quotes; otherwise, all the keys would need to have the same number of words for this to work.upper case
.settings.json
re-add_
to word separators.轻松使用查找和替换。参见 regex101 demo
find:
(^\ s+')(^\ s+')([^'')* )'
替换:
$ 1 \ u $ 2'
\ u
将大写以下捕获组$ 2
。使用
^
在行开头启动查找,使得仅针对“键”(第一个'
-delimmited字符串),而不是其他以下字符串。Easy with Find and Replace. See regex101 demo
Find:
(^\s+')([^']*)'
Replace:
$1\U$2'
The
\U
will uppercase the following capture group$2
.Starting the find at the beginning of the line with
^
makes it easy to target just the "keys" (the first'
-delimmited strings) and not the other following strings.