How to edit all lines in Visual Studio Code

后端 未结 7 1407
余生分开走
余生分开走 2020-12-23 12:20

I have a list of data to which I need to put a \' symbol at the start of the line and at the end of the line. So the original data looks like this:



        
相关标签:
7条回答
  • 2020-12-23 12:32

    You could edit and replace with a regex:

    Find (Ctrl+F):

    ^(.+)$
    

    Replace:

    '$1'
    

    This regex finds any content on a line and wraps it inside quotes. The $1 refers to whatever is matched inside the parentheses in the regex. In this case, it's "one or more characters" i.e. everything on the line. Be sure to tick the regex icon.

    If every line may or may not have a space before the content, and you want every line to have a space, try this:

    Find:

    ^ ?(.+)$
    

    Replace (notice the space before the first quote):

     '$1'
    
    0 讨论(0)
  • 2020-12-23 12:32

    Here is an easy way to do this:

    1. Ctrl+A to select all or select your desired text.

    2. Shift+Alt+I to put a cursor at the end of each line.

    3. Type your ' (or whatever you want at the end).

    4. Home will move all your cursors to the beginning of the lines.

    5. Type your ' (or whatever you want at the beginning of all the lines).

    0 讨论(0)
  • 2020-12-23 12:47

    You can use Find and Replace.

    Besides, paste to Excel and using a function to add character '.

    0 讨论(0)
  • 2020-12-23 12:48

    The first thing that came to my mind - replace abcde with 'abcde' line by using option Find and Replace option. I'm pretty sure Visual Studio Code has something similar to that.

    0 讨论(0)
  • 2020-12-23 12:54

    You can use the Alt + Shift shortcut.

    1. First press Alt + Shift then click the mouse button on the first line.

    2. Go to the last line, and then do the same.

    This will mark all the parts of one side. Whatever you type will be reflected in the marked spaces.

    Do the same on the other side too.

    0 讨论(0)
  • 2020-12-23 12:54

    Use Toggle Multi curosr Modified from action pane.

    Select the cursor points with ctrl + <Mouse click> , you can modify everything simultaneously.

    This will require lots of manual efforts if lines are more

    0 讨论(0)
提交回复
热议问题