How can I remove duplicate lines in Visual Studio Code?
Answer a question
Say you have the following text:
abc
123
abc
456
789
abc
abc
I want to remove all "abc" lines and just keep one. I don't mind sorting. The result should be like this:
abc
123
456
789
Answers
Coming in vscode v1.62 is a command to eliminate duplicate lines from a selection:
Delete Duplicate Lines
in the Command Palette
or
editor.action.removeDuplicateLines
as a command in a keybinding
(there is no default keybinding for this command)
Here is a very interesting extension: Transformer
Features:
-
Unique Lines As New Document
-
Unique Lines
-
Align CSV
-
Align To Cursor
-
Compact CSV
-
Copy To New Document
-
Count Duplicate Lines As New Document
-
Encode / Decode
-
Filter Lines As New Document
-
Filter Lines
-
Join Lines
-
JSON String As Text
-
Lines As JSON String Array
-
Normalize Diacritical Marks
-
Randomize Lines
-
Randomize Selections
-
Reverse Lines
-
Reverse Selections
-
Rotate Backward Selections
-
Rotate Forward Selections
-
Select Highlights
-
Select Lines
-
Selection As JSON String
-
Sort Lines By Length
-
Sort Lines
-
Sort Selections
-
Split Lines After
-
Split Lines Before
-
Split Lines
-
Trim Lines
-
Trim Selections
Unique Lines
Removes duplicate lines from the document Operates on selection or current block if no selection
Unique Lines As New Document
Unique lines are opened in a new document Operates on selection or current block if no selection
I haven't played with it much besides the "Unique Lines" command but it seems quite nicely done (including attempting a macro recorder!).
更多推荐
所有评论(0)