Column Mode Insertion in Visual Studio Code

Asked

Viewed 75 times

0

Good morning! In Visual Studio Code column mode, activated either by the middle mouse button or by the combination with the Alt key, how can I insert something in all lines, but in the same column? For example: I have the following lines below:

São Paulo
Campinas
São José dos Campos
Santos
Piracicaba

then I want to insert, in this example, the literal "SP" in a column in front of the names of the cities, like this:

São Paulo            SP
Campinas             SP
São José dos Campos  SP
Santos               SP
Piracicaba           SP

I still haven’t found this facility. It always inserts at the end of each row, getting:

São PauloSP
CampinasSP
São José dos CamposSP
SantosSP
PiracicabaSP

Another detail: I don’t always enter information by simple typing. I paste the information from the desktop. So if ALWAYS I need to mark the column on all n-lines, it will become counterproductive, as I may have situations with thousands of lines.

See function animation in action in the IDM Ultraedit editor: Inserção em coluna com [CTRL+V]

  • This answers your question? Indent code in Visual Studio Code

  • It’s not indentation, because it depends on the file type. What I’m looking for is an easy way to insert data (pasting or typing) into a given column for all selected rows. It would be a tabulated text.

  • look ai https://imgur.com/a/axymMx9

  • Good morning, hugocsl! Today I do this. For a few lines it is suitable and efficient, but I can have situations that insert thousands of lines. One more detail that I originally did not indicate: I want to paste information into that column. Ever imagined I have to always select all n-lines? I would like to click on a column and apply the OS collage (the popular Ctrl+V).

1 answer

0

What makes there a column in a plain text file is the spacing. In this case there, it is not so simple to leave exactly the same, but can do something like the example below:

inserir a descrição da imagem aqui

After selecting all the text, secure CTRL+ALT+I to enter edit mode on all lines.

  • 2

    Take a look ;) https://answall.com/questions/317037/indentar-c%C3%b3digo-no-visual-studio-code/317039#317039

  • Good morning, David! This I already do, but in many situations the number of lines is thousands and this technique is laborious and inefficient. I usually insert several spaces/tabs, then mark the column I want (in column mode) in all lines using Alt or mouse center button, insert a symbol, that usually the semicolon, then start to swap all the occurrences of semicolon and a space, by a semicolon only until they are extinguished. For...

  • ...continuing: Another editor I use a lot is IDM’s Ultraedit. It has this function and that is why I would like to find a similar way to implement it in VSC. I’ve searched for extensions and I haven’t found anything like it yet.

  • 1

    The solution of @hugocsl seems to solve very well, thanks!

  • But for situations involving thousands of lines it is laborious. Deal with many unstructured data imports and this feature is essential to the performance of my tasks. I have other means you use, such as software combination (IDM Ultraedit) with VSC. And in VCS use Python to manipulate the data, but ... I need to have a minimum structure of data in text, because visually is faster.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.