News for hackers. Stuff that matters.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by wayneftw on Sunday December 15, 2019 @02:18PM (#21798279)
> "move the cursor to a certain place and enter some text"

In vscode, I'm usually already looking at the call site of a function I want to edit. So I move the cursor into the function call and hit F12 which takes me to the function definition to edit it. Once I'm done, I hit Alt+LEFT to navigate back to where I was to continue on...

If I didn't start from a call site but I know the file I want to edit - I hit Ctrl+P, type the name of a file, hit ENTER - now I'm in the file, ready to edit it.

To jump to a function, I collapse all functions (Ctrl+K,Ctrl+0/1/2/3/4) and then scroll (or PAGE UP/DN) to find it...then use arrow keys or Ctrl+G to enter the line number. Now I'm ready to edit the function. I might have to hit Ctrl+Shift+] to expand the body of the function.

Alternatively, I Ctrl+F and type the name of the function I want to edit, pressing ENTER to find it...and I'm ready to edit the function.

What do you do in vim that is far easier?

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by stevelosh on Sunday December 15, 2019 @02:48PM (#21798492)
You're talking about how it's easy to move to a function or a file, and then you're "ready to edit", but edanm is talking about actually doing the editing.

For example: say I jump to this function and want to fix a bug (the `search` should strip off the first two characters here, not just one). So I need to change `regex.search(s[1:], ...)` to `regex.search(s[2:], ...)`:

    def compile_hg_glob(line):
        pat = glob_to_re(line)
    
        # Mercurial ignore globs are quasi-rooted at directory boundaries or the
        # beginning of the pattern.
        pat = '(^|/)' + pat
    
        # Mercurial globs also have to match to the end of the pattern.
        pat = pat + '$'
    
        try:
            regex = re.compile(pat)
            return lambda s: regex.search(s[1:] if s.startswith('./') else s)
        except:
            warn("could not parse hgignore pattern '%s'" % line)
            return lambda s: True
If I've just used a fancy shortcut key to jump to this function, my cursor is probably on the function name. In Vim, I'd do `cinr2:<esc>`. Seven keystrokes. I could also do `/[<cr><ctrl-a>` which is only four keystrokes, but a little more awkward to reach. If I tried to do this editing with arrow keys and backspaces I'd need 12 down keystrokes just to get to the right line.

Or suppose I'm looking at this and want to add a `,` character to the end of each of the type entries, because I forgot Python likes its commas:

    result = result | {
        'a': TYPES_ALL
        'e': TYPES_FILE_REAL
        'x': TYPES_FILE_SYMLINK
        'c': TYPES_DIR_REAL
        'y': TYPES_DIR_SYMLINK
        'f': TYPES_FILE
        'd': TYPES_DIR
        'r': TYPES_REAL
        's': TYPES_SYMLINK
    }[c.lower()]
In Vim I'd press `j` to get to the first entry, then `A,<esc>` to append the `,` after the first one, then `j.` to move down and repeat the action. I then press `j.` a bunch more times (which is really easy to do rapidly with your index and ring finger on Qwerty) and in 2 seconds I'm done. Vim's `.` to repeat the last action is really powerful and can save you a ton of time for small ad-hoc edit repetitions that don't warrant doing a full macro with `q`.

These kinds of things happen constantly, and when you've got Vim burned into your fingers trying to edit text without it (actually edit text, not just jumping to something) feels like typing with oven mitts on.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by manigandham on Sunday December 15, 2019 @04:38PM (#21799164)
Or just use the mouse to point and click in the same time. With laptop mousepads it's just moving a finger. Most devs aren't writing that much code and all these Vim efficiencies are vastly overstated.

I've seen many Vim/Emacs-only devs being easily beaten in speed by others using modern IDEs that have tooling and functionality (auto formatting, refactoring, templating, etc) focused on actually getting things done.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by eloff on Sunday December 15, 2019 @07:51PM (#21800043)
Exactly this. I pick type, and I've never found that it feels too slow. I spend more time thinking about the change I want to make, and reading the code to plan that, than actually making the change most of the time. My typing speed wouldn't address the bottleneck. I think vim is the same. Sure you can edit the text faster, but that's not the bottleneck anyway.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by iLemming on Tuesday December 17, 2019 @01:54PM (#21817184)
Vim was never about typing efficiency. However, it is indeed the best way to navigate and edit text. This statement is very subjective because, just like any tool, it depends on the user. Chainsaw looks ugly, heavy, cumbersome and dangerous to someone who doesn't know how to use it. But with some practice it becomes an incredibly efficient tool. People make ice sculptures using chainsaws.

And I'm not talking about Vim the editor. I'm talking about Vim as an idea. Which is today implemented for pretty much every single [popular] editor and IDE in use. That fact alone is pretty illustrative of awesomeness of the idea of Vim.

And the comment about Emacs is quite disingenuous. I have never been inside a Formula One cockpit, but I can totally get "the job done" with my Camry, because it is totally more efficient for parallel parking.

I have used many IDEs, including InteliJ (which I used for about seven years). Emacs wins solely by its extensibility, no editor/IDE has ever matched its capabilities. For some people that is not an important factor, just like the efficient parallel parking might not be important for Formula One pilots. But when you can automate pretty much anything it feels very empowering and liberating.

Small example: when I'm about the create a new commit, an emacs-lisp script can figure out the current ticket I'm working on (based on currently clocked Org-mode task), generate a branch name based on the ticket description, generate part of the commit message (in the way that it is in compliance with git tool like gommit), I would just have to type the rest of the message.

That is not only more efficient, but also reduces frustration. Compare that with the workflow in any other editor and IDE - most of these steps will have to be manual. Then someone might say: oh there's actually a plugin for Editor X that does some of that stuff for Jira. But what if I join a different company that uses Pivotal Tracker instead? I can extend my emacs-lisp script. Whereas if that's an InteliJ plugin I would either have to go through daunting process of forking and modifying the plugin or submit a feature request and wait for something that may never happen.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by nickysielicki on Sunday December 15, 2019 @09:02PM (#21800296)
I switched to vscode recently from emacs and was embarrassed about how much more productive I was, almost immediately.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by Aeolun on Sunday December 15, 2019 @07:30PM (#21799953)
I think where the IDE’s are really powerful is when refactoring. Need that one class renamed? File is automatically renamed too, and all references in every file that link to it (instantiations, calls, imports) are updated too.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by manigandham on Sunday December 15, 2019 @09:04PM (#21800304)
Exactly, the code structure, navigation and intellisense features are far more useful and let you code at the same level of abstraction as the logic you're coding.

Moving a little bit faster through the text file to edit characters is rarely the issue and I certainly wouldn't give up IDE features for it.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by jiofih on Sunday December 15, 2019 @02:58PM (#21798554)
1: ctrl-f, 2:, esc

2: select the first :, ctrl+d until all are selected, right arrow, comma

Doesn’t sound any more efficient? Plus, who writes code without an auto-formatter these days? Problem two would have been solved by the linter the moment you wrote that.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by edanm on Sunday December 15, 2019 @03:12PM (#21798663)
It's not just code and linting though - this kind of thing happens when you're editing YAML files, when you're editing pure text, when you're editing CSVs, when you're editing some obscure thing no one's heard of - once you have the primitives down, it's just so easy to apply it everywhere.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by jiofih on Monday December 16, 2019 @06:58AM (#21802428)
Did you read what I just wrote? Those commands are not specific to any language.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by edanm on Monday December 16, 2019 @07:24AM (#21802527)
Sorry, I was referring to the second part (about the linter.)

Obviously the first part is language-neutral, and is exactly why I think multiple cursors is one of the greatest inventions in text editing! :)

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by edanm on Sunday December 15, 2019 @03:14PM (#21798675)
This is a bit frowned upon in HN, but may I just say I'm a fan. I'm not sure, but it's likely I got my way of speaking of vim as a language from you, and as you can see in my other comments, it's stuck with me :)
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by earenndil on Sunday December 15, 2019 @02:59PM (#21798563)
> In Vim I'd press `j` to get to the first entry, then `A,<esc>` to append the `,` after the first one, then `j.` to move down and repeat the action. I then press `j.` a bunch more times (which is really easy to do rapidly with your index and ring finger on Qwerty) and in 2 seconds I'm done. Vim's `.` to repeat the last action is really powerful and can save you a ton of time for small ad-hoc edit repetitions that don't warrant doing a full macro with `q`.

Eh. I'd probably do 'qqA,<esc>j0q', and then '8@q'.

That's also probably not the best example, since that's also trivial if you have an editor supporting multiple cursors.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by edanm on Sunday December 15, 2019 @03:10PM (#21798655)
That's hardcore, I would rarely use a macro for something like that :)

That said, I think multiple cursors are the greatest addition to text editing since, well, vim. I was an enthusiastic user of Sublime Text 1, right before I learned about vim.

Luckily, vim has multiple cursor support, which is... decent. Not great, but decent. I actually think that the only thing that makes multiple cursors more awesome, is being able to combine them with vim's commands, since multiple cursors rely on you being able to do precise things at each cursor, and vim gives you the language for it.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by stevelosh on Sunday December 15, 2019 @03:12PM (#21798669)
> That's also probably not the best example, since that's also trivial if you have an editor supporting multiple cursors.

Yeah, it's hard to come up with a decent example because I don't even think about it any more, it's just burned into my fingers. I just know how excruciating it feels to edit without Vim (I even wrote that last comment in Vim and then copied it into the browser because writing it in a text field is miserable).

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by edanm on Monday December 16, 2019 @08:52AM (#21802958)
I long ago created a special script (in Macos it's via something called Hammerspoon, I used to have a Windows version).

It basically gives vim-like keys anywhere you want, when holding down the caps lock key. So e.g. caps+h/j/k/l are movement keys.

It goes a lot farther than that: I have a key to delete a line, a key to select a word, a key to go up/down by 4 lines, a key to delete the last word, etc. I even mapped caps+f to jump forward 20 characters (to badly simulate using 'f [letter]' in vim).

This makes so it I never have to leave home position on the keyboard, because while holding caps I have all the movement keys I want at my disposal. It's a total lifesaver, and the only way I can effectively use a keyboard outside of vim :)

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by DeepVim on Sunday December 15, 2019 @03:37PM (#21798814)
I guess even easier would be to go to the visual mode, then selecting all the lines and append the commas all at once :)

<c-v>8j$A,<esc>

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by sicariusnoctis on Sunday December 15, 2019 @04:02PM (#21798954)
Isn't `$` is redundant
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by earenndil on Sunday December 15, 2019 @06:30PM (#21799710)
Not in visual mode.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by cgriswald on Sunday December 15, 2019 @06:37PM (#21799733)
For your second example, I'd do :2,8s/$/,/<enter>
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by savanaly on Sunday December 15, 2019 @02:45PM (#21798472)
>So I move the cursor...What do you do in vim that is far easier?

The part about moving the cursor. Vim users typically don't move the cursor with the mouse but rather with the keyboard. Having to move your hands off the keyboard to reach for the mouse then back is the part that starts to feel sluggish if you get used to not doing it.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by dmitriid on Sunday December 15, 2019 @05:20PM (#21799372)
Before a vim'er finishes typing yet another command to find that one specific text, a mouse user will have already clicked where needed :)
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by viklove on Monday December 16, 2019 @11:26AM (#21804190)
Quite the opposite actually, by the time your hand even finds the mouse the vim user will already have jumped to the desired code block and have started editing it.
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by dmitriid on Tuesday December 17, 2019 @02:04AM (#21811345)
Having worked alongside longtime vim users, that's almost never the case. There's often more time spent on finding out/remembering the efficient way to get to a particular piece of code. And then there are the inevitable mistakes (oh, I counted give spaces/quotes/paragraphs, but there was one more/one less; oh, I failed to account for some minor thing in my macro etc.).

In a modern IDE you have a multitude of shortcuts and a mouse, and they complement each other.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by viklove on Tuesday December 24, 2019 @11:45AM (#21873193)
> Having worked alongside longtime vim users, that's almost never the case. There's often more time spent on finding out/remembering the efficient way to get to a particular piece of code.

Longtime vim users who didn't know how to use vim? That's... interesting.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by nik_0_0 on Sunday December 15, 2019 @02:43PM (#21798458)
Reading the parent comment (and being somewhat a vim user) - "move the cursor to a certain place and enter some text" - sounds mostly about the first thing you mentioned - "move the cursor".

Stock vim is mouseless, and without arrow-keys, which means relying on /? (searching) or other keys to achieve the function of arriving at text. CTRL-F never quite matches that (after you hit enter, the CTRL-F dialog is still open, and needs to be closed with ESC or by clicking away), and moving to the arrow keys/pgup/pgdown/mouse is slow.

Having said that - there are some plugins that match this behaviour - I particularly like the ones where a key (f in vimium) highlights each word with a character, allowing for one or two keypresses to jump anywhere on the screen.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by s_kilk on Sunday December 15, 2019 @05:24PM (#21799396)
I do all of the same in emacs (and vim), and because I use doom-emacs I get all this basically for free without much configuration on my end.

- Go-to-definition is `g d` (with the cursor over the function name in question)

- Project-wide file search is `SPC SPC`

- Jumping to a function is `SPC s i` and then just start typing to fuzzy-match the function name

I stick with this setup because it does pretty much everything I could want from IDEA, and does it without churning up most of the resources on my machine. And trust me, I've tried to switch to IDEA, but it's just too big and too slow, and too poor of an editor for me to actually make the switch.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by thawaway1837 on Sunday December 15, 2019 @03:00PM (#21798570)
Even something simple like reading code line by line (and of like me you like to move the cursor as you read the line), and your cursor reached the bottom of the screen, and you want reset the viewport where the line the cursor is on is at the middle of the viewport, is one keystroke ‘M’
Re:JetBrains: $270M revenue, 405K paying users, $0 raised by scooble on Sunday December 15, 2019 @05:47PM (#21799510)
All that can be done in vim.

The one related function that I would miss is using vimgrep and the QuickFix list to get a list of the locations where the function name appears which I can use e.g. to do a search and replace in those files (or a subset of them)

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by edanm on Sunday December 15, 2019 @02:47PM (#21798486)
It's not so much the moving between the files - which vim is terrible at (one of the many things I had to extend in vim in order to get it to work like an IDE). But it's moving and editing within the file itself.

E.g., say you somehow got to a file, and it now has a bunch of functions in it, and you're literally looking at the line you want to edit. To get to that line, there's a bunch of different ways, but you can do this in like 3 key presses. Then, within the line, you can change anything in it really easily.

This sounds weird, so I'll try to give an example. Let's assume you have something like:

Func(self._something, self.something_else).validate, 'Validate exam foundation table')

And let's say you want to change the string that says 'Validate [...]' to say 'Change is good!!'.

To do that, once you've gotten to the line, I'd probably hit two key presses that mean "go to the first open quote in the line", then I'd hit the keys that mean "delete everything inside of the quote character", then I'd type what I want. All in all, I'd be typing these characters before actually writing what I want to write: f'ci' (so, 5 characters).

That probably looks either idiotic or daunting - but the idea of vim is that it's a language - you are literally thinking in your head "go to that quotation mark", then tell vim to do that and it does. Then you're thinking "delete everything inside of these quotations", and it does it. The distance between thinking what you want to do and doing it is almost zero - it's as close as you can get to literally telling someone exactly what to do.

If you're using a non-vim editor, you'd probably have your cursos in the begining of the line, and have to do "cmd+right" several times to skip over words in order to get to the first word of the string, then have to "shift+cmd+right" to get to the end of the string, then write what you want.

There might also be some small annoyances - the last shift+cmd+right might take you over the last quotation mark, and you'd end up selecting the closing paren as well. In vim - that doesn't happen, you're saying exactly what you want to have happen.

Or you might want to undo this change - in vim, it's always hitting "u" once, because in vim, changing the string to something else is an atomic motion. In another editor, you might have to undo a few words at a time, or maybe not - it's not always predictable. And since it's atomic in vim, it's also easy to re-apply the same action to another string - so changing another string to the same thing is a simple matter of hitting "." on it.

And of course, this is just a tiny example. It's easy to dismiss as trivial or unimportant - these are tiny savings of time, after all, and even if you add it up, I doubt the "time saved" in doing things more efficiently is worth much.

But once you know this language for telling an editor exactly what to do, then using an editor that doesn't speak that language just feels super slow - it feels like you are not able to communicate properly, and suddenly, what used to be zero gap between thinking and doing, takes a long time.

Re:JetBrains: $270M revenue, 405K paying users, $0 raised by dmitriid on Sunday December 15, 2019 @05:25PM (#21799397)
> If you're using a non-vim editor, you'd probably

Double-click the word to select it, and start typing right away.

> it's as close as you can get to literally telling someone exactly what to do.

I usually tell someone "Change the word 'validate' to 'something else'". SO i grab my mouse/trackpad, and get there in one click (or double-click).

> It's easy to dismiss as trivial or unimportant - these are tiny savings of time, after all

You should observe most of these "savings" in real life. There's rarely a time when I can't do stuff with code faster than a Vim user. Because by the time the vim user has typed the required sequence of letter, or counted which line/symbol/mark to go to, or wrote a macro correctly, I'll have finished all I needed to do using IDEs built-in capabilities and/or a mouse.