查看 vscode 中未保存的更改

use*_*032 8 visual-studio-code

有时在关闭 vscode 或其中的选项卡时,我会收到一个对话框,询问“是否要保存所做的更改filename?” 但是,未保存的编辑实际上来自上一个会话,该会话在没有此类查询的情况下关闭,可能是在关闭计算机时,所以我不记得它是否是有意义的编辑,或者可能只是一个意外的按键,例如快捷方式出错了; 并且undo重新访问上次编辑也不起作用。

我的问题:如何查看保存的文件版本与编辑器窗口中的版本之间的差异?我认为最好在对话中有一个“show diff”选项,但现在我对命令行 diff 命令也很满意。

我正在使用 ubuntu 20.04。

kkm*_*kkm 20

对于键盘手来说,有一些亮点:

\n
    \n
  • 您询问的命令有一个默认快捷方式。除非您应用了键盘映射扩展,否则Ctrl+Kd琶音会在当前文件的活动版本和已保存版本之间打开完全相同的差异视图。关闭编辑器选项卡(无论是差异、文件还是任何其他内容)的默认快捷方式是Ctrl+W
  • \n
  • The command, like any command in VSCode, is also accessible via the Ctrl+Shift+P command dropdown (on Linux, F1 opens it too). Start typing e.g. compa sav (it saves your keyboard wear and tear to shorten words to a prefix which is unambiguous enough), and the list will shrink dynamically to just a few commands. Yours is File: Compare Active File with Saved. When it's close to the top enough, navigate the list of commands with the down arrow and execute it with Enter. As a bonus, you may click on the little gear to the right of the command currently highlighted in the list and redefine its shortcut, if you use it very often and prefer a chord shortcut to the default arpeggio one. Sorry, there does not seem to be a shortcut in lieu of the gear click. If there is, please let me know!
  • \n
\n\n
    \n
  • But if you really, really want to right-click on the filename in the Open Editors view of the Explorer sidebar, you can open that view directly with, you guessed it, a shortcut: Ctrl+Ke. And if you change your mind on a dime right at this moment, or realize that you in fact never had a mouse to do the right-click in the first place, use Shift+F10 to drop down the "right-click menu", properly called the context menu, which you navigate with arrows and execute with Enter (that's kinda a common theme, as you probably noticed). This works mostly anywhere the right-click does.
  • \n
  • While in the Open Editors view, to switch to an editor file tab, move the selection to the desired file. Press Space to bring the file into view but stay in the Open Editors view, or Enter to bring the file into view and shift the keyboard focus to it. Pressing Ctrl+Shift+E brings focus back to the editor from any view in the Explorer sidebar. The same shortcut moves focus to the Explorer sidebar from the editor.
  • \n
\n

Happy \xe2\x99\xac k'boarding \xe2\x99\xac!

\n


cra*_*ing 11

我在 MacOS 上使用 VSCode 1.52.1 版,我遇到了类似的问题,可能不是同一个问题,但我猜它也适用于您。

当您在 Explorer 视图中时,在 Explorer 的左上角有您的“打开编辑器”。如果左侧显示一个点表示缓冲区中有更改,您可以右键单击文件名并选择“与已保存的比较”。这将在旁边打开另一个缓冲区,该缓冲区将显示任何未保存的更改。

要摆脱那个窗口(我花了一点时间才弄明白,我很抱歉地说!),您可以单击“打开编辑器”中额外缓冲区左侧的“X”。

希望这对你有用!

  • 当您右键单击编辑器选项卡时,他们应该将“与已保存的比较”添加到上下文菜单中。我没有保持“打开编辑器”面板打开,因为选项卡基本上是相同的列表。 (6认同)
  • 谢谢,这有效!要关闭比较视图,您还可以单击选项卡中的 x。他们确实应该将其添加为密切确认对话中的一个按钮。 (2认同)

Dav*_*ong 8

ctrl+shift+P(或在 Mac 上为 command+shift+P)并模糊搜索“将更改与保存的文件进行比较”

  • 我想现在它说“将活动文件与保存的文件进行比较” (2认同)