Duplicate Line In Visual Studio Code



If the order of lines is not important

Sort lines alphabetically, if they aren’t already, and perform these steps:
(based on this related question: How do I find and remove duplicate lines from a file using Regular Expressions?)

  1. Control+F
  2. Toggle “Replace mode”
  3. Toggle “Use Regular Expression” (the icon with the .* symbol)
  4. In the search field, type ^(.*)(n1)+$
  5. In the “replace with” field, type $1
  6. Click (“Replace All”).

If the order of lines is important so you can’t sort

Duplicate selection or line. Duplicte functionality like you are used to. Adds duplicate text functionality to vscode similar to that in Sublime Text or Resharper. When nothing is selected, the whole line is duplicated and caret is placed on the lower line; When text is selected, the selection is duplicated and the new copy is selected. Saya mencoba menemukan jalan pintas untuk menduplikasi baris dalam Visual Studio Code (saya menggunakan 1.3.1) Saya mencoba CTRL+ yang jelas Dtetapi tampaknya tidak berhasil. Visual-studio-code — TheWebGuy sumber 3. Ctrl+K,X or?,Tab (Visual Basic) Surround With: Ctrl+K,S: Show Quick Info: Ctrl+K,I: Navigate To: Ctrl+, Navigate highlighted references: Ctrl+Shift+Up (Previous) Ctrl+Shift+Down (Next) Editor zoom: Ctrl+Shift+ (In) Ctrl+Shift+line up/down: Alt+Up arrow / Alt+Down arrow: Duplicate line: Ctrl+E,V: Expand selection. For those migrating from WebStorm/PhpStorm, Duplicate lines = CTRL + D Move a line/selection of code Up/Down = Ctrl + Shift + UP / DOWN. Check duplicate lines in the file content or selection, and remove them if you need to keep the unique lines only. 🆕Since v0.1.0, DupChecker uses cuckoo-filter to speed up checking progress, and be able to handle large files with 100k+ lines.

In this case, either resort to a solution outside VS Code (see here), or – if your document is not very large and you don’t mind spamming the Replace All button – follow the previous steps, but in steps 4 and 5, enter these:
(based on Remove specific duplicate lines without sorting)

Find Duplicate Lines In Visual Studio Code

How to make duplicate line in visual studio code

Caution: Blocks for files with too many lines (1000+); may cause VS Code to crash; may introduce blank lines in some cases.

  • search: ((^[^S$]*?(?=S)(?:.*)+$)[Ss]*?)^2$(?:n)?
  • replace with: $1

and then click the “Replace All” button as many times as there are duplicate occurrences.

You’ll know it’s enough when the line count stops decreasing when you click the button. Navigate to the last line of the document to keep an eye on that.

From

https://stackoverflow.com/questions/37992493/how-to-remove-duplicate-lines-in-visual-studio-code

Condividi:

Duplicate Line In Visual Studio Code Free

Mi piace:

Mi piaceCaricamento...

Visual Studio Code Vertical Select

Correlati

%d blogger hanno fatto clic su Mi Piace per questo:

ReSharper | Edit | Duplicate Text
Control+D
ReSharper_DuplicateText

One of the ways of creating a code element similar to an existing one (for example, a new method overload or a new auto-implemented property) is cloning the existing element with copy-paste and then editing the clone.

Visual Studio Copy Line Shortcut

ReSharper helps you streamline the cloning part — with a single keystroke Control+D the cloned code is inserted right after the original.

Quickly duplicate the current line or selection

  1. If you want to clone a line, set the caret at this line line. To clone an arbitrary piece of code, select it in the editor.

    To select a logical code block, press Control+W one or more times; to select the current declaration, press Control+Shift+OemOpenBrackets.

  2. Press Control+D or choose ReSharper | Edit | Duplicate Text from the main menu. Alternatively, you can press Control+Shift+A, start typing the command name in the popup, and then choose it there.

  3. The duplicated line or multi-line selection is inserted below the original line or selection; the duplicated inline selection is inserted to the right of the original.

  4. If you have duplicated a selection, the selection stays at the clone. If necessary, you can press Ctrl+Shift+Alt and then use arrow keys to move the clone to the desired position.

This feature is supported in the following languages and technologies:

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.

Duplicate Line In Visual Studio Code

Visual Studio Duplicate Row

Last modified: 08 March 2021