News for hackers. Stuff that matters.
Re:VS Code can do that? by solipsism on Saturday April 21, 2018 @01:10PM (#16892227)
I don't know how people program without this feature

You must do some kind of programming I've not encountered in my many years. While my editor of choice can do this, I would have no idea how, because a feature like "increment duplicates" is needed so infrequently that I would never remember the shortcut.

Re:VS Code can do that? by monkpit on Saturday April 21, 2018 @03:23PM (#16892907)
That quote was referring to column editing mode, not “increment duplicates” shortcut.
Re:VS Code can do that? by derimagia on Saturday April 21, 2018 @02:05PM (#16892462)
It's one of those things that is incredibly useful. Of course it's possible to survive without it, but it's like saying "I don't know how people program without Copy and Paste". It helps.
Re:VS Code can do that? by khedoros1 on Saturday April 21, 2018 @11:05PM (#16894509)
Copy and paste is something that I use many times a day, even when I'm not programming. Needing to do the same edits over multiple lines doesn't happen often in my code.

There are appropriate plugins available for my editor, but I've never felt the need to install them.

Re:VS Code can do that? by staticassertion on Sunday April 22, 2018 @12:52AM (#16894763)
I don't use this as much as copy/paste, but I absolutely use it daily.
Re:VS Code can do that? by staticassertion on Saturday April 21, 2018 @04:23PM (#16893243)
Increment duplicates is just one of many, many utilities that pairs well with multiple carets.

Formatting is another.

Boilerplate code, for example today I had to implemented code like this:

    impl Into<Node> for ProcessNode {
      fn into(self) -> Node {
        Node {some_boilerplate(self)}
      }
    }
I had 6 node types. Using multiple cursors I:

* Implemented it once

* Duplicated it 5x

* Copied the names of the types I needed to impl for

* Attached a cursor to each impl

* Used ctrl + left/ right to word-jump, and past in the appropriate area

Now it's not like this saved me more than a minute or two, but this sort of thing is extremely common in my experience, across languages.

Re:VS Code can do that? by xfer on Saturday April 21, 2018 @04:55PM (#16893391)
Or you could write a macro?
Re:VS Code can do that? by staticassertion on Saturday April 21, 2018 @06:49PM (#16893790)
That sounds like considerably more work.
Re:VS Code can do that? by kazinator on Sunday April 22, 2018 @02:51PM (#16897815)
In Vim (on Unix), type this into the buffer

  for x in type1 type2 type3 type4 type5 type6 ; do
    cat <<!
      impl Into<$x> for ProcessNode {
        fn into(self) -> $x {
          $x {some_boilerplate(self)}
        }
      }
  !
  done
Now do a line-oriented visual select of all the lines from for to done (using V + cursor movements). Then pipe to shell with !sh[Enter].

Poof! The above is replaced with the following:

      impl Into<type1> for ProcessNode {
        fn into(self) -> type1 {
          type1 {some_boilerplate(self)}
        }
      }
      impl Into<type2> for ProcessNode {
        fn into(self) -> type2 {
          type2 {some_boilerplate(self)}
        }
      }
      impl Into<type3> for ProcessNode {
        fn into(self) -> type3 {
          type3 {some_boilerplate(self)}
        }
      }
      impl Into<type4> for ProcessNode {
        fn into(self) -> type4 {
          type4 {some_boilerplate(self)}
        }
      }
      impl Into<type5> for ProcessNode {
        fn into(self) -> type5 {
          type5 {some_boilerplate(self)}
        }
      }
      impl Into<type6> for ProcessNode {
        fn into(self) -> type6 {
          type6 {some_boilerplate(self)}
        }
      }
Don't write in some insane boilerplate-driven programming language in the first place. Anyone proliferating this kind of duplication (whether with multi-cursors or shell here docs or any other way) should be flogged.
Re:VS Code can do that? by khedoros1 on Saturday April 21, 2018 @11:08PM (#16894516)
I've got to agree. It's one of those things that could save me a minute of manual editing every once in a long while, but I feel like there have to be lower-hanging fruit, in terms of increasing my editing speed.