Programing

Visual Studio Code-메모장 ++ 용 플러그인과 같은 비교 기능이 있습니까?

lottogame 2020. 7. 4. 10:40
반응형

Visual Studio Code-메모장 ++ 용 플러그인과 같은 비교 기능이 있습니까?


Notepad ++ 용 플러그인과 같은 비교 기능이 있습니까?


탐색기의 파일을 작업 파일 섹션 또는 폴더 섹션에서 비교할 수 있습니다. 명령 팔레트에서 전역 비교 작업을 트리거 할 수도 있습니다.


첫 번째 파일을 마우스 오른쪽 버튼으로 클릭하고

여기에 이미지 설명을 입력하십시오

그런 다음 두 번째 파일을 마우스 오른쪽 버튼으로 클릭하고

여기에 이미지 설명을 입력하십시오

스크린 캐스트 :

vscode에서 파일을 비교하는 방법


여기 제가 가장 좋아하는 방법은 "비교를 위해 선택하고 다음과 비교 ..."단계보다 조금 덜 지루하다고 생각합니다.

  • 왼쪽 파일을 엽니 다 (편집 할 수 없음)
  • F1 활성 파일과 비교 ...
  • 오른쪽 파일 선택 (편집 가능)-드롭 다운 목록에서 최근 파일을 선택하거나 탐색기 패널에서 파일을 클릭 할 수 있습니다.

이것은 프로젝트 디렉토리에없는 파일을 포함하여 임의의 파일과 함께 작동합니다. 제목없는 파일 2 개를 새로 작성하고 텍스트를 복사 / 붙여 넣기 할 수도 있습니다.


Visual Studio Code 버전 1.27.2가 있으며이를 수행 할 수 있습니다.

두 파일 비교

  1. 두 파일을 Visual Studio Code로 끌어서 놓기 여기에 이미지 설명을 입력하십시오
  2. 두 파일을 모두 선택 하고 상황에 맞는 메뉴에서 비교위해 선택을 선택 하십시오.여기에 이미지 설명을 입력하십시오
  3. 그럼 당신은 diff를 참조하십시오 여기에 이미지 설명을 입력하십시오
  4. Alt+ F5 사용 하면 다음 diff로 이동할 수 있습니다여기에 이미지 설명을 입력하십시오

두 개의 인 메모리 문서 또는 탭 비교

때로는 두 개의 파일이 없지만 내용을 먼저 파일에 저장하지 않고 어딘가에서 텍스트를 복사하고 빠르게 비교하기를 원합니다. 그런 다음이 작업을 수행 할 수 있습니다

  1. Ctrl+를 N두 번 눌러 개의 탭을 엽니 다 .여기에 이미지 설명을 입력하십시오
  2. Paste your first text sample from the clipboard to the first tab and the second text sample from the clipboard to the second tab
  3. Select the first document Untitled-1 with Select for Compare: 여기에 이미지 설명을 입력하십시오
  4. Select the second document Untitled-2 with Compare with Selected: 여기에 이미지 설명을 입력하십시오
  5. Then you see the diff: 여기에 이미지 설명을 입력하십시오

Another option is using command line:

code -d left.txt right.txt

Note: You may need to add code to your path first. See: How to call VS Code Editor from command line


There is plugin called Partial Diff which helps to compare text selections within a file, across different files, or to the clipboard.


In your terminal type:

code --diff file1.txt file2.txt

A tab will open up in VS Code showing the differences in the two files.


Right click on 1st file click "Select for compare".

Click 2nd file click "Compare with selected"


I found a flow which is fastest for me, by first associating a keyboard shortcut Alt+k to "Compare Active File With..." (#a). (Similar to wisbucky's answer but further improved and more step-wise.)

Then, to compare two files:

  1. Open or focus file B (will be editable in compare view by default). E.g. by drag-drop from File Explorer to VS Code's center.
  2. Open or focus file A.
  3. Press Alt+k, a quick open menu will be shown with file B focused.
  4. Press Enter.

Result: file A on left and file B on right. (Tested on VS Code 1.27.1)

Remarks

#a - to do so, press Ctrl-k Ctrl-s to show Keyboard Shortcuts, type compare on the top search box, and double click the "Keybinding" column for "Compare Active File With...", press Alt+k then Enter to assign it.


If you want to compare file in your project/directory with an external file (which is by the way the most common way I used to compare files) you can easily drag and drop the external file into the editor's tab and just use the command: "Compare Active File With..." on one of them selecting the other one in the newly popped up choice window. That seems to be the fastest way.


다음 은 확장을위한 마켓 플레이스 링크 입니다. 확장명 "비교"는 현재 프로젝트와 컴퓨터 또는 클립 보드의 다른 디렉토리에서 선택할 수있는 두 파일을 비교하는 데 도움이됩니다.

참고 URL : https://stackoverflow.com/questions/30139597/visual-studio-code-is-there-a-compare-feature-like-that-plugin-for-notepad

반응형