News for hackers. Stuff that matters.
Re:Vim is touch-typing on steroids by calvinmorrison on Thursday January 12, 2023 @11:01PM (#34363793)
Every few years I trot out some vim command new to me and it falls to the wayside. I don't even use buffers right, I use tabs. Which are apparently a bastardized version but I digress.

F f g G jkl; ESC i r R yy p and control A and control E probably cover 90% of my cases.

However. I use a nub on my ThinkPad so I have sort of instant mouse access for location things, I mostly use jumping for inside a line

Re:Vim is touch-typing on steroids by doix on Thursday January 12, 2023 @11:09PM (#34363847)
Buffers and tabs serve different purposes. I think a lot of people dismiss tabs because they don't understand their purpose. It's not just about switching to different buffers quickly.

Tabs are an organized collection of windows, and you can quickly switch between them. I might organize my windows so half the screen is one buffer and on the other half, is split 3 times horizontally. Then I edit some code and realize I need to edit some other part of the codebase. I make a new tab instead of changing buffer, so I can go back to the view I setup already without having to recreate it.

Tabs are the true power of vim, I don't have that functionality in any other editor (apart from Emacs?) and I miss it constantly. Buffers aren't really a novel concept, they work the same in VS code and JetBrains IDEs.

Re:Vim is touch-typing on steroids by pxc on Thursday January 12, 2023 @11:20PM (#34363901)
> Tabs are the true power of vim, I don't have that functionality in any other editor (apart from Emacs?)

Yeah, Emacs also lets you do that! You can achieve similar workflows via tmux or a tiling window manager as well. It's my favorite way to work! For whatever reason I've never gone down the tiling WM rabbit hole, but I use this kind of thing in Emacs and tmux all the time.

Re:Vim is touch-typing on steroids by doix on Friday January 13, 2023 @12:14AM (#34364201)
So I do use a tiling window manager, but the problem is that to take advantage of it, I'd need the editor to put each buffer in its own (real xorg) window. I couldn't get something working with either vscode or IntelliJ.

One editor that does support it, is kakoune. I forgot about it when writing my previous comment. Each instance can connect to a server, so they can all share registers/buffers/etc. Then you can use tmux or your window manager to create the layout you want.

It's very clever, I actually think it's superior to vim, as you aren't limited to organizing your views inside a single vim "main" window. You could do stuff like kak | browser | kak, and both kak instances share everything.

Unfortunately I can't get used to the kak commands so I'll probably never change. Perhaps neovim will one day implement something similar.

Re:Vim is touch-typing on steroids by sodapopcan on Friday January 13, 2023 @12:00AM (#34364131)
Ya, "tabs" are a misnomer coming from almost any other editor which is unfortunate. Vim doesn't have what most people think of as "tabs" (I guess you could think of them as "dynamic" tabs but I digress).

Vim has been my only code editor for the past 10+ years and I wish I used tabs a little better (ie, the way you describe). As it stands I have some plugins that open in a tab so they are easy to close (like gv.vim) and otherwise use my tabline as a secondary status line (it tells me my working directory and if I'm tracking a session or not).

Re:Vim is touch-typing on steroids by Aperocky on Friday January 13, 2023 @12:34AM (#34364315)
airline and bufferline plugins are great - it helps unify/bridge buffer and tabs
Re:Vim is touch-typing on steroids by sodapopcan on Friday January 13, 2023 @09:51AM (#34368459)
I never liked airline as I felt it was too busy and I like customizing my own statusline, though you've piqued my interest with how they deal with tabs. I actually like vim's tabs just as they are--I mostly need better mapping for manipulating them. I'm otherwise a dual-split-with-a-mark-or-two person.
Re:Vim is touch-typing on steroids by deathanatos on Friday January 13, 2023 @01:26AM (#34364562)
Try :normal (:norm for short.) It can edit a set of lines given a certain set of vim commands. Sometimes simpler to reason with than regexes.

E.g., if you want to turn,

  * a
  * b
  * c
into,

  "a",
  "b",
  "c",
V, highlight the lines, :norm 2xi"^[A", — 2x to remove the star+space, i" to insert the quote — now we need to get out of insert mode, so that's tricky: Type ^V ESC there for verbatim ESC (I've rendered that in the command as vim will, ^[, but it will be colored to denote that it's a real ESC character) — then A", (append a quote and a comma).

You could do it with a regex, but I just find it far more natural to list the commands: my brain is already imaging it that way: remove the bullet, add the quotes and the comma.

Good for-loop for "do this to each line". Sometimes takes a bit of back & forth to construct the command, or sometimes it's just easier to do multiple :norm's. One of the best additions to my repertoire in years.