3 ms·
It's certainly a decent way of doing things, but it's not like if you don't use vim you're gonna sit there clicking around and re-typing the same thing 200 time
by hbn 4y ago
It's certainly a decent way of doing things, but it's not like if you don't use vim you're gonna sit there clicking around and re-typing the same thing 200 times.
Here's how I'd do it with IntelliJ on my Mac:
* Probably grab the list into my clipboard the same way with ls (pipe output into `pbcopy` then paste into the editor)
* Put an editing carat on each line. Maybe there's a better way but I'd usually select a newline character then Cmd-ctrl-g to select all instances of newline in the file
* Cmd-left to jump to the beginning of the line. Type the <a href=" (which will edit every line) then Cmd-right to jump to the end of the line and finish off the tag. (I feel like this is already faster than the method shown which involved more typing)
* For grabbing the titles of the PDFs, it certainly isn't as flashy but I'd probably just open the folder in Finder, side-by-side it with my editor, and look at the preview that's built into Finder. Cmd+tab to jump focus between the editor and finder to hit the down arrow key to highlight the next document.
Maybe doesn't look as sexy overall, but I don't think it would take any longer than what was shown here. And it doesn't really require me the brainpower of building complicated commands and trying to recall obscure operations like "disown". So it's not really selling me on giving up all my IDE's smarts and facing the daunting learning curve if it's not really gonna save me time.
- kamaal 4y agoActually macros do a lot more than search-replace, including things repeating key strokes across several buffers(tabs in vim). In Emacs you can even have incantations, to open connections to remote servers with tramp etc. Some times things like inserting text after three(or 'n') words etc etc. This can be hard to do by a straight search-replace. There's a big difference between manipulating text and these sort of tasks. You will surprised just how many repeated tasks you do without you even knowing you are. At times there are even patterns in places where one things there is total randomness. And many times some people might not be aware that a particular editing pattern saves effort if done through a macro than done manually.
- 0x4d464d48 4y agoFor me, a lot of the value add comes from being able to open up files from a terminal, almost instantly, and make changes way quicker than I would through an IDE. It's also much faster when doing trivial and repetitive changes. If you're interested you can look up how macros work in Vim. You can automate entire sequences of key strokes which goes beyond 'find and replace'. It's awkward at first but after you master it it becomes second nature and feels like you're working at the speed of thought. When I have to use an IDE I usually try and install a Vim plugin.
- SAI_Peregrinus 4y agoJetBrains IDEs have a comprehensive scope-aware custom macro system, "live templates".
- bun_at_work 4y agoI was thinking similar things while watching the video - my thought was to use column selection mode to create the link tags, though. It's basically the same flow as cmd+ctrl+g to get the new lines.
- oniony 4y agoThis is one of many ways of doing this in Vim: you pick the way depending upon the task and what you prefer. Personally I would have used macros in this situation. Recorded my commands and replayed them across the resultant lines. It's actually interesting to see another Vimn user's approach. Whilst what you're saying is correct about being able to do these things on your IDE/editor, one of the strengths of Vim comes from being able to program edits and then reuse them. I'm always stunned programmers don't naturally get drawn to Vim for this reason alone. And I actually use Vim bindings in my IDEs, giving me the tools from both worlds. For example, if I made a macro that does all of the edits on a single line, I can replay that macro n times or – better still – play it only on lines that match a regular expression. You can basically describe the edits you want to make either by recording you making them (macro), or – like on this video – by hand constructing them. Either way you can then apply them like a distinct action (procedure) however you want. Example: `:g/blah/s/a/b/g` will search (g) for all lines matching "blah" then substitute (s) "a" with "b" for all occurrences (g). Similarly `:g/bl.*ah/norm @a` will play my macro in register `a` across all the lines that match the regular expression `bl.*ah`.
- smaudet 4y agoMultline edit obvs is good, I find regexp generally better in more complex scenarios. Main problem obvs is getting every non blank line. The rest of the workflow is ofc what I'd already do, you can do this with any number of tools these days, vim (nor IntelliJ) is not exceptional here...
- intel_brain 4y agoexcept the fact that you spent $$$ compared to the $ he spent for just the hardware to run vim. And you are still slower.