How to paste a multiline selection as an aligned straight column after lines of varying length?

独自空忆成欢 提交于 2021-01-29 10:26:27

问题


My source file looks like

123456789
456
789

and I want to paste the following text appending to the end of the each line

abcd
efgh
hijk

the desired output should be as follow (which can be done in ultraedit)

123456789 abcd  
456       efgh  
789       hijk  

but with vscode I can only get

123456789   abcd
456   efgh
789   hijk

Can anyone can show me how?


回答1:


Using my answer from Pad selected lines to cursor position in VSCode but using a smaller number, like 10.

from within the macro at the link modify the following line:

      // keep first 10 characters, increase/decrease to suit your needs but always overshoot
      "snippet": "${TM_SELECTED_TEXT/(.{10}).*/$1/g}",

The idea is to include more spaces than you are likely to need and then keep only the first 10 characters - so your values + enough spaces to equal 10 total characters. Depending on your likely values, choose a sufficiently higher number to get your column of cursors beyond where you will likely want them to end up - it is easy to move them left/right as a straight group afterwards if need be.

[And make sure the setting Multi Cursor Paste is set to its default option spread.]

In the demo the macro keybinding alt+s doesn't show up for some reason but that is all I used to get the column of cursors aligned to the right of your values between the copy and paste.



来源:https://stackoverflow.com/questions/59980304/how-to-paste-a-multiline-selection-as-an-aligned-straight-column-after-lines-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!