#VimTip

Balakrishnan Balasubramanianbalki@balki.me
2025-06-18

I run few maintenance tasks occasionally ~ once a month. I note down when I ran like below:

# Last run Wed 18 Jun 2025 12:24:39 PM EDT
ssh vps1 runStuff.sh

To update the date, I used to run :r!date and then edit to replace.
I wrote a small command to automate that

command DateUp keeppatterns s/Last run \zs.*EDT/\=system("date")->trim()/

#vim #vimtip

Menno Finlay-Smitsmenno@hachyderm.io
2025-03-05

TIL, in #vim (or #neovim) you can indent the current line *while in insert mode* with Ctrl-T and dedent it with Ctrl-D.

I've used Vim for decades and have always switched to Normal mode and used << and >>. This is so much better!

:help ins-special-keys is full of gems. #VimTip

Kevin Bowen (has moved) :xfce:kevinbowen@fosstodon.org
2025-02-19

Little shout out to past me for throwing this config in my .vimrc ages ago:

" Toggle spellcheck functionality
:map <F5> :setlocal spell! spelllang=en_us<CR>

Now I get to rebuild some lost muscle memory for fixing my speeling mesteaks

vimtricks.com/p/vim-spell-chec

#Vim #VimTip

2025-01-28

TIL about `<C-a>` and `<C-x>` in #vim for adding or subtracting.
(`:h ctrl-a` , `:h ctrl-x` )

Ctrl-a will add [count] to a number or alphabetic character at or after the cursor.
And Ctrl-x will do subtraction in the same way.

For example let's say I need to increment this 1 to be a 2.

```
replicas: 1
```

Normally I would type `f1` followed by `r2`
Or maybe even just `A` <backspace> `2`

But we can do better.

In this particular scenario I need only be on that line and do `<C-a>`
Since `<C-a>` will look ahead to find a digit on the current line and act upon it. Which means we can do this from the start of the line and it will turn into:

```
replicas: 2
```

And if I want to change it back to `1` I can use `<C-x>`

These two commands will even take a `[count]`. This means that if the current value is `replicas: 1` we can do `10<C-a>` and it will now say `replicas: 11`

#vim #vimtips #VimTip #TIL #vi

2025-01-26

For my fellow #vim people.

Delete a group of lines with `:N,Nd`

For example:

```
1 this
2 is
3 an
4 example
: 2,3d <- Delete lines 2-3
```

This also works with other verbs in vim. For example copy (`y`) , change (`c`), indent (`>` or `<`),

You can even combine these action verbs with additional modifiers or commands for more powerful functionality.

For example:
`1,5>>` indents lines 1 through 5 by two levels.

`1,10!tr a-z A-Z` converts lines 1 through 10 to uppercase using the `tr` command.

Edit: Fixed an example for newer Vim versions Thanks @m1foley 🀘

#VimTip

a66ey πŸ‡ͺπŸ‡ΊπŸ³οΈβ€πŸŒˆ she/hera66ey
2024-01-23

So I just mapped F5, F6 and F9 (good old quick save - quick load habbit) to select all, copy and paste in VIM and life is so much more easier when using just general register for copy-paste jobs. Proceed like so:

:nmap <F5> ggVG

...

#vim

#vimTip of the day, if you've opened two files in a split and what to sync the scrolling in the two panes execute

:set scrollbind

in both of the files, and it syncs up the scrolling, it's wonderful when working on a derivated configuration, and you use an existing file as a template.

RastalRastal
2022-07-25

: Open any script in , move the cursor to any command in the script, then use Shift + k to jump to a man page for that command.

Possibly *the* most useful function in vim, especially if you read a lot of scripts!

miccaman βœ”οΈmiccaman
2021-11-17

.,$ Range: $ is till end of file. (And not G)

Free Pietje πŸ‡΅πŸ‡Έ πŸ‰FreePietje@x0f.org
2021-05-06

@jb55
#VimTip hashtag? ;-)

(To be consistent, the 'other' one should probably be #GitTip (singular))

Free Pietje πŸ‡΅πŸ‡Έ πŸ‰FreePietje@x0f.org
2020-10-15

@juliank
If you haven't watched it yet, I highly recommend
youtube.com/watch?v=wlR5gYd6um
(especially the first ~24 mins)

Mentioned in the video is this SO post: stackoverflow.com/a/1220118

Those will learn you to 'think in vim' terms, which is what makes it so powerful.

#vim #VimTip

Free Pietje πŸ‡΅πŸ‡Έ πŸ‰FreePietje@x0f.org
2020-07-20

@sir
It shouldn't be too hard to remember: *m*ark
m a = mark identified by letter a
' a = go to mark a

But use what works best for you.
That you know it's called a mark (and not bookmark f.e.) in #vim, hints that you already knew it.

Still, it's a good #VimTip

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst