News for hackers. Stuff that matters.
Re:Seven habits of effective text editing (2000) by lighthazard on Monday October 23, 2017 @09:02AM (#15532831)
How do I select Lines 3, 16, 39, 50, 230, 420, 1302, and 2300 at random columns of my needs? With a mouse, I can cntrl/cmd + click the line I am interested in, wherever I am interested, and do any manipulation I want. Can VIM do this easily? I've never tried.
Re:Seven habits of effective text editing (2000) by dredmorbius on Monday October 23, 2017 @09:13AM (#15532909)
And, in all earnestness: why are you doing that?

Is there something about those specific line numbers intrinsically? Is there a pattern or specific text on those lines? Is there a relationship to surrounding text, above or below?

The great thing about vim, or a set of similar tools (ed, ex, sed, awk, perl, cut) is that you can address the text in terms of the text itself. Search by text or regex, move within a line or between lines. Replace text or modify elements, preserving some and changing others.

Or, if I know in advance that I've got to deal with the 8 specific lines mentioned but without otherwise addressible context: 3G <edit stuff> 16G <edit stuff> ... 2300G <edit stuff>.

That's not elegant, but it's doable and fast.

Re:Seven habits of effective text editing (2000) by lighthazard on Monday October 23, 2017 @09:32AM (#15533030)
Line numbers were irrelevant, just a set of random numbers. There is no pattern to the text (say it's a set of words that needs to be edited to become the same). I guess this is more related to working with large blocks of text rather than code. Someone mentioned macros, I'm going to give that shot.
Re:Seven habits of effective text editing (2000) by dredmorbius on Monday October 23, 2017 @11:53AM (#15534084)
What's the characteristc of the text and how do you identify it?

Again, search, paragraph and sentence navigation, and word nav are intrinsic to vim, and fast. If you know what you're looking for, "/<pattern>" and you're there. With incremental search ("set ic" in your ~/.vimrc) thats often a very few keystrokes.

Re:Seven habits of effective text editing (2000) by ATsch on Monday October 23, 2017 @09:19AM (#15532947)
What are you trying to accomplish with this? If you are trying to replace multiple cursors, the approach would be very different.

What I'd do is record a macro for the edit on one line into q, and then apply it to all relevant lines with a regex, e.g. g/regex/norm @q

Re:Seven habits of effective text editing (2000) by bananicorn on Monday October 23, 2017 @09:08AM (#15532873)
Maybe you're looking for visual block mode?[0] Or the multi-cursor plugin[1]? I haven't tried the latter, ut I really like visual block mode for certain things.

It's amazing how much new stuff I learn about vim every day... And I'm nowhere near done :)

[0]https://stackoverflow.com/questions/21806168/vim-use-ctrl-q-... [1]https://github.com/terryma/vim-multiple-cursors

Re:Seven habits of effective text editing (2000) by aoloe on Monday October 23, 2017 @09:12AM (#15532900)
it depends on what you want to do... but my general reflex is:

- go to line 3

- start recording a temporary macro ("qq" in my habits)

- do the editing

- stop the macro ("q")

- go to the line 16 with 16gg and reply the macro with @q - 39gg@q

- 50gg@q

- ...

Re:Seven habits of effective text editing (2000) by bananicorn on Monday October 23, 2017 @09:16AM (#15532929)
this. Macros are something I've never used in other editors, but in vim they're simply... fun to use.

Well, if used for the right purpose.