this post was submitted on 17 Jul 2024
83 points (97.7% liked)

Ask Experienced Devs

1232 readers
1 users here now

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

I'd like actual examples instead of "I work faster", something like "I can move straight to the middle of the file with 7mv" or "I can keep 4 different text snippets in memory and paste each with a number+pt, like 2pt", things that you actually use somewhat frequently instead of what you can do, but probably only did once.

you are viewing a single comment's thread
view the rest of the comments
[–] BodaciousMunchkin@links.hackliberty.org 4 points 3 months ago* (last edited 3 months ago)

A godsend for saving time - the ab (abbreviation) command. This command lets you shorten a long sequence of characters (be it a text or a complex command) into another sequence of any length. It works in both insert mode and command mode. If you frequently edit text using a lengthy command, this feature will significantly save you time. For example: :ab ul s/\<./\u&/g to capitalize every word in a line. When you enter command mode (type :) and type ul, vim will automatically expand it to s/\<./\u&/g for you.

Additionally, the map command can save even more time, but IMO the ab command offers more control for handling various cases. In my example, you can use ul to only capitalize the lines that have a specific pattern using the global command g.

Another overlooked aspect is the .exrc file. Enabling it with set exrc in your config allows for different setups based on different situations. For instance, when writing notes, I prefer to have line breaks on to make the text look nicer on the screen. In contrast, when writing code, I don't require this option. I simply need to place set linebreak in the .exrc file in the note-writing directory to adjust accordingly.