home.social

#vimtip — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #vimtip, aggregated by home.social.

  1. Daily Vim Tip: From any bracket, brace, or parenthesis, % teleports you to its matching partner. In files with the matchit plugin loaded, it also hops between if/else/end blocks and HTML tags.

    Learn more: run `vimtutor` in your terminal, or use `:help %` inside Vim.

    #vim #vimtip #coding #ostechnix

  2. Daily Vim tip: Use f{char} / F{char} to move the cursor at a specific character on the current line. f jumps forward to it; F hunts backward. After the first jump, ; repeats in the same direction and , reverses — so you can skip through multiple matches without retyping.

    Learn more: run `vimtutor` in your terminal, or use `:help f{char}` inside Vim.

    #vim #vimtip #coding

  3. Daily Vim Tip: Use e / E to land on the final character of the current word rather than the start of the next. Handy when you want to append to a word or delete to its tail. E skips punctuation just like W does.

    Learn more: run `vimtutor` in your terminal, or use `:help e` inside Vim.

    #vim #vimtip #coding #ostechnix

  4. Vim tip of the day: b / B

    Use b or B to move backward through Words. b treats every punctuation cluster as its own stop; B leaps back across entire non-space chunks at once. Pair with w to zip through code without touching arrow keys.

    Learn more: run `vimtutor` in your terminal, or use `:help b` inside Vim.

    #vim #vimtip #coding

  5. #vimtip Better #man support when editing shell script.

    autocmd filetype sh,bash,zsh {
        g:no_man_maps = 1
        g:ft_man_open_mode = 'vert'
        runtime ftplugin/man.vim
        setlocal keywordprg=:Man
    }
    autocmd Filetype man {
        nnoremap <buffer> <silent> q :q<CR>
        setlocal keywordprg=:Man
    }
    

    Pressing K loads the man page of word under cursor in a vertical split. q closes it. See also https://vimhelp.org/filetype.txt.html#manpager.vim

    #vim #vim9script

  6. 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

  7. 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

  8. 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

  9. 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

  10. #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.

  11. #VimTip : Open any script in #vim, 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!