5 ms·
> On (2), length, I don't recall any of my meta editing tasks involving "100 keystrokes and a mouse movement." Customizable shortcuts can trim down the outliers
by swombat 15y ago
> On (2), length, I don't recall any of my meta editing tasks involving "100 keystrokes and a mouse movement." Customizable shortcuts can trim down the outliers.
As a simple example of that, using a dumb text editor like notepad as the baseline, changing the same 10 characters on 10 consecutive lines will take at least 200 keystrokes (100 DELs, 100 times typing the same characters back in, plus the movement keys - about 9 to move down to the next row.
With a bit of thought, in notepad, you can reduce this a bit. use Ctrl-C and Ctrl-V to reduce the amount of typing - but you'll still need to either DEL or select the words to replace, in the same location on each line.
With a more modern text editor, you can select a rectangular area and replace the text within it. In vi, replacing those 10 strings on 10 consecutive lines will take (starting at the first character to replace, like Notepad, and assuming it's a single word inside separators):
Ctrl-V e 1 0 j c A_NEW_WORD
That's 16 keystroke instead of over 200, with no mouse movements.
This is something I do frequently enough that I didn't need to even think for a millisecond to bring to mind the keystrokes needed to do it.
Now, I'm not arguing your editing style isn't different - maybe you've never needed to do this - but I would argue that this is a fairly common programming text editing task.
- mayanksinghal 15y agoIn a dumb Editor: 1. Ctrl-shift-Right to select (1 or 3) 2. Ctrl-C copy (1 or 2) 3. Ctrl-H Open replace dialog box (1 or 2) 4. Ctrl-V Paste the old (1 or 2) 5. Tab (1) 6. A_NEW_WORD (10) 7. Enter (1) 8. Replace (1) x10 (or Tab + replaceAll == 2) 9. Escape (1) ------------- Total 27 or 32 That >80% Better. On an intelligent IDE: 1. Right Click Key (1) 2. R - to choose refactor (1) 3. R - Rename (1) 4. A_NEW_WORD (10) 5. Enter (1) ---------------- Total: 14 I still want to learn Vim, because I somehow find it 'artistic'. There is some inherent beauty in Vi that I would love to be a part of. Unfortunately, the learning curve is fairly steep and the fear of losing productivity for 2 weeks is too huge. I still use vi for small changes, but for coding I find eclipse a more useful tool.
- Ideka 15y agoYou forgot to take the conversion rate between clicks and keystrokes into account. c = (k.d.t.r) / 13333337 Where: c = click k = keystroke d = distance in centimeters between the "J" key and mouse t = area to be clicked in pixels² r = screen resolution in pixels²
- mayanksinghal 15y agoThere are no clicks, the Right Click Key on keyboard is just too awesome! :)
- sirclueless 15y agoThere's another giant advantage to renaming in an IDE over a text editor: You can be sure not to clobber any other variable/method references. Here's an example, I want to change the name of my MyClass.Execute() method to something more descriptive. In an IDE, I right click and rename and I'm done. In vim or other plaintext editors this is practically impossible without manually inspecting each call-site. Is "foo.Execute()" a reference to MyClass.Execute() or YourOtherClass.Execute()? Without actually parsing the program it's tough to know. I love using vim, and I'm getting better at it the more I use it, but this is one of the major productivity drains I encounter that an IDE does way better.
- DrewG 15y agoWhy do you have the same 10 characters on 10 consecutive lines? Sounds like that is probably a violation of DRY, at least it always has been when I encountered something like that. Also, if you are comparing vi(m) to something, please don't compare it to notepad. Every editor and IDE I have used in the past few years has rectangular selection. Commonly with alt+click and drag, or shift+alt+arrow keys.
- sophacles 15y agoThere are lots of scenarios when this comes up: - braindead configuaration files. - data files that need some massaging - commenting out code blocks in languages which need a prefix comment delimiter on each line (e.g. python's # or haskell's --) - any time you are doing a series of operations calling functions in a module or from a single class/object and the name changes (e.g. foo.x();, foo.y(); foo.z(); and so on);
- DrewG 15y agoOK, I can potentially see where vi(m)'s rectangluar selection would be good for editing config files and such, but I'm pretty sure all modern editors have rectangular selection anyway (notepad is not a modern editor). My IDE has the ability to rename a variable and to comment/uncomment a selection which solves your last two problems.
- sophacles 15y agoI wasn't defending vim over your editor, just answering the question of when there are valid times to do 10 lines of block change. 2 more that came up for me yesterday: We changed the data format being sent over JSON now I needed to: 1) make a bunch of int declarations into float declarations, fortunately those tend to bunch up. 2) Change a bunch of getInt calls to getFloat calls, but those are also bunched up together.
- losvedir 15y ago> Ctrl-V e 1 0 j c A_NEW_WORD Another approach is something like: *:.,+9s/<ctrl-r>//A_NEW_WORD But alas, that's 21 keystrokes. (I post this now because it was closer to my first thought on how to approach the problem, and wanted to write it out to see if it was shorter. It wasn't, but maybe it'll be useful to someone. I learned about <ctrl-r>/ (fills in a search and replace with the previously searched expression), while writing it.