this post was submitted on 28 Jun 2023
5 points (85.7% liked)

Linux

8185 readers
416 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 1 year ago
MODERATORS
 

I know not everyone likes using vim but I thought those who do could share a good reason to get into it. For me its the repetition of the last change with the push of the dot key. Replace the current word with another and move the cursor to the next word you wish to replace. It makes the editor so versatile and feels very satisfying.

top 9 comments
sorted by: hot top controversial new old
[–] mekkagodzilla 6 points 1 year ago (1 children)

I use vim macros all the time. For example, you have a bunch of lines that need the same 3 operations done:

  • insert " at the beginning of the line
  • insert ", at the end on the line
  • indent

Press qa, do what you need to do on one line and go one line below, press q again to stop recording the macro, then you can do it 50 times with 50@a.

[–] valen 3 points 1 year ago

I've done this a lot too. It's the kind of thing where someone watching says "what is this black magic and how do I got to make the text said what I want?".

[–] humdrumgentleman 5 points 1 year ago (1 children)

For me, the moment it clicked was the first time I used it on my laptop. It was just so darn comfortable, and made me realize I was hesitant to do certain work without a mouse until that moment. My hands had to move around so much less, and that made for a much more enjoyable experience.

[–] [email protected] 1 points 1 year ago

Yeah, using the console on my laptop made it so much more usable.

[–] trachemys 3 points 1 year ago

The yank buffer is useful, but sometimes I’ll do an action that replaces the yank buffer, when I wanted to save that text. So put:

map K “_

in your .vimrc. Now you can use shift-k before a command to make it not update the yank buffer. For example: go to a word and type yw to copy the word. Go to another word and type KdwP to delete the word and paste your saved word. Alternately, you can also type Kcw then type something and ctrl-R followed by “ to paste.

[–] anthimatter 2 points 1 year ago

I started with vi on Solaris so Vim was a damn luxury to use. Not having to use a mouse or a GUI in server environment is a must. Even with all the cool editors out there now I still find myself using it even in X11 environments. Mastering it is a real achievement that you can be proud of because it's never not worth your time.

[–] udon 2 points 1 year ago (1 children)

I think these two talks by Chris Toomey sum up pretty well everything that is nice about vim:

  1. https://www.youtube.com/watch?v=wlR5gYd6um0
  2. https://www.youtube.com/watch?v=lwD8G1P52Sk

If you've used vim for a while now and feel a bit stuck, they bring you to the next level and are pretty straightforward.

That said, other editors also have their pros and I've become a bit tired of looking for the most efficient one or so. It really doesn't matter in my job if I need x hours or y hours to write something (although vim probably scores well there). I use it nowadays mostly because it works well for me, it feels kind of fun, it doesn't eat my computing resources, and it's here to stay (free).

[–] [email protected] 2 points 1 year ago

Thank you for the resources, I'll try them once I get the chance to work on a project for awhile again. The reasons why you like it are great to hear, as many videos tend to focus on speed over other aspects. If speed was my only concern I could have stayed with an IDE which I knew how to use. For me vim is both exciting to learn as a skill and convenient because of it's server friendly interface.

[–] marswarrior 1 points 1 year ago* (last edited 1 year ago)

I use vimv to bulk rename files, either from lf file manager or straight from terminal. I really like using macros like @mekkagodzilla mentioned. or I replace words using sed format :%s/old_word/new_word/g combined with regex when needed. Relative line numbers to jump lines.
Youtuber ThePrimeagen is an expert at using everything vim related.
Here's a playlist of his vim lessons you might like.