home.social

#vimtips — Public Fediverse posts

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

  1. Stop editing at 10% of Vim's power. Master registers, :norm, fuzzy completion, linematch diff, and 16 more Vim tips and tricks. Tested on latest Vim 9.2.

    Full guide here: ostechnix.com/vim-tricks/

    #Vim #Vimtips #Vimtricks #Editor #Opensource #Linux

  2. #VimTips I had to look for again to remove duplicate lines in my visual selection :

    :sort u

    The `u` makes it [u]nique 😉 It helped me…

    #Vim #NeoVim

  3. Oh, look! Another ✨exciting✨ #Neovim #cheatsheet for all two people still using #Vim. Because clearly, the biggest problem with Vim is *remembering the keys*, not *escaping the editor*. 🔑💥👨‍💻
    nvim-cheatsheet.vercel.app/ #Developer #Community #VimTips #HackerNews #ngated

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

  5. This fixes all my complaints wrt text search and a highlighting

    set nohlsearch
    set incsearch

    #vimtips #vim #neovim

  6. Nice. You can specify how large a new window in by adding numbers beforehand.

    So ctrl+w and 20v

    or

    :vertical 20 new

  7. Copy to system clipboard from #vim guide:

    1. In your ~/.vimrc set
    set clipboard=unnamed

    2. Open a file and yank whatever you want, in this example we yank lines 4 and 5 to system clipboard; in command mode, type 4,5y *
    set ts=2
    set sts=2
    set sw=2
    filetype off
    filetype plugin indent on
    syntax on
    set expandtab

    3. Profit
    Paste anywhere you want
    filetype off
    filetype plugin indent on

    #vimTricks #vimTips

  8. And when you need the full completion madness in the command line, for example when you're editing complex Regular Expression statements, simply type `q:` from normal mode and you get the full Vim editing power in an editable command history window.
    Simply type your command line statement (or select an older one) and press <CR> to execute the command line under the cursor. See :help q:

    #Vim #Vi #Editor #Programming #VimTips #VimTricks

  9. #Vim hint of the week (because I'm searching this regulary again):
    You can insert the word under the cursor while in command mode with:
    <CTRL-R><CTRL-W>
    This comes in handy when you want to [s]ubstitute a word, without having it to retype again.

    :%s/<CTRL-R><CTRL-W>/newWord/g

    #Vim #Vi #Editor #Programming #VimTips #VimTricks

  10. @rixx for really good #VimTips I'd recommend the book "practical vim". It is not just full of great Tips, but also explains why some things work differently in (neo)vim

  11. #VimTips got a healthy subconscious Ctrl+S reflex from other editor's? Use :up in vim for you for your file saving reflex. The :update command saves your file only if there are changes. Meaning: you can spam this command without causing unnecessary writes.