在python3foratom中使用f字符串时,它不能正确地自动完成字符串。输入
types_of_people = 10
x = f"There are {types_of_people} types_of_people."
我开始键入时得到x = f"...
,但结束引号不能自动完成
当我输入结束引号时,我得到x = f"There are {types_of_people} types_of_people."""
我怎样才能让结束报价自动完成?在
我去了这个链接。但是atom在我输入结束引号时仍然会打印额外的引号,而不仅仅是给出结束引号。在
方法1
添加一个snippet以自动完成
f-string
,如建议的here。在您可以通过编辑位于
%USERPROFILE%/.atom
目录中的snippets.cson
文件来添加代码段。也可以通过选择Edit
菜单下的Snippets...
进行编辑。在编辑文件时,键入
snip
,然后按TAB。它应该生成一个示例配置,如下所示:将上述内容编辑为:
^{pr2}$在这种方法中,
f-string
的自动完成只在键入f"
后按TAB来触发<2进近
在atom编辑器的相应配置文件中添加以下行:
init.coffee
keymap.cson
配置文件
init.coffee
可以通过选择Edit
菜单下的Init Script...
选项来编辑,keymap.cson
文件可以通过选择Edit
菜单下的Keymap...
选项进行编辑。这些配置文件位于%USERPROFILE%/.atom
目录下。在编辑配置文件后,关闭并重新打开atom编辑器。在编辑器中(对于python特定的文件),输入
f"
,它应该自动完成为f""
。光标位置应该在两个双引号之间。在这个方法的灵感来自于这个答案here。在
在方法2中,有另一种方法可以使括号匹配程序包认为它只是添加普通括号对。{需要禁用括号中的匹配项
向
init.coffee
配置文件添加以下行:试试这个
我认为问题的发生是因为您使用
in
作为对象。尽量避免这样。在相关问题 更多 >
编程相关推荐