[英]How can I prevent VS Code from jumping to the bottom of a file after formatting?
How can I prevent VS Code from jumping to the bottom of a file after formatting?格式化后如何防止VS Code跳到文件底部?
I select the whole file content (using the Ctrl + A
), then I format everything (using the Alt + Shift + F
).我 select 整个文件内容(使用
Ctrl + A
),然后我格式化所有内容(使用Alt + Shift + F
)。 After that I would expect my file to be formatted and the view not to move.之后,我希望我的文件被格式化并且视图不会移动。 The file gets formatted, but the view jumps to the bottom.
文件被格式化,但视图跳到底部。
How could I prevent this jumping?我怎样才能防止这种跳跃?
When you are doing Ctrl+A
your cursor is implicitly moved to the end of the selection, hence the end of the file.当您执行
Ctrl+A
时,您的 cursor 被隐式移动到选择的末尾,因此是文件的末尾。 Therefore, your cursor is not moved at the end by the formatting but by the selection.因此,您的 cursor 最后不是由格式移动,而是由选择移动。
The solution is to format the whole file (with Alt+Shift+F
) without selecting the content before ( Ctrl + A
).解决方案是格式化整个文件(使用
Alt+Shift+F
)而不选择之前的内容( Ctrl + A
)。
Moreover, in your case, Ctrl+A
was useless because you are using the shortcut for formatting the entire document.此外,在您的情况下,
Ctrl+A
没用,因为您使用的是格式化整个文档的快捷方式。 If you only want to format a selection, the shortcut is Ctrl+K Ctrl+F
.如果您只想格式化选择,快捷键是
Ctrl+K Ctrl+F
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.