home.social

#vimtrick — Public Fediverse posts

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

fetched live
  1. #vimtrick
    open vim in diff mode:

    vim -d file1.c file2.c

  2. really nice #vimtrick to align columns 🤯

    1. visual select
    2. replace separator by separator+spaces (e.g.: `:s/=/= /)
    3. place cursor after longest word on first column
    4. remove extra whitespace with `dw`

    stackoverflow.com/questions/12

  3. nice #vimtrick:

    :g/^#/#

    when editing markdown, prints a ToC to jump to the header you want.
    vimrcfu.com/snippet/165

  4. #vimtrick
    q: how to break a line at cursor position (and keep on normal mode)?
    a: press "R" "Intro" "Esc" keys

  5. #vimtrick
    q: how to scroll both files/windows at the same time?
    a: `:set scrollbind` in both windows (`:set noscrollbind` to disable)

  6. #vimtrick
    q: how do i activate spellcheck in vim?
    a: `:setlocal spell spelllang=es`

    q: how do i deactivate it?
    a: `:setlocal spell!`

  7. #vimtrick
    q: how do i jump to the next double-quote (")?
    a: press `f"`, or `F"` to go backwards

  8. #vimtrick
    q: what's the difference between `cw` and `cW`?
    a: a word (lowercase w) ends at any punctuation OR white space, while a Word (uppercase w) ends only at whitespace

  9. #vimtrick
    q: how do i resize a split window?
    a: either write `:30winc >`, press "30" "Ctrl+W" ">" or write `:vertical resize 60`

  10. #vimtrick
    q: how do i make the split windows size equal?
    a: press "Ctrl+W" "="

  11. #vimtrick
    q: how to open a link under cursor with browser?
    a: press `gx`

  12. #vimtrick
    q: how to show the complete path of the actual file?
    a: press "1" "Ctrl+G"

  13. #vimtrick
    q: how to copy a word and go replacing other words with that?
    a: `yiw` (yank in word), `viwp`(select a second word, then replace with first)

  14. #vimtrick
    q: how to insert #html tags easily?
    a: first `:imap <C-t> <></><Esc>5hdiwp3lpT>i`, then write ex.: div, press Ctrl+t and insert content

    coderwall.com/p/1omscg/vim-eas

  15. #vimtrick
    q: what to do with code already written with tabs?
    a: after setting the above, `:set retab`

    stackoverflow.com/a/427004

  16. tinkering with someone's code 😇
    noooo he used tabs! so if i press tab now, it doesn't work properly!!

    #vimtrick
    q: how to set tab = 4 spaces?
    a: `:set tabstop=4spaces`, or better: `set tabstop=4 softtabstop=0 expandtab shiftwidth=4`

    stackoverflow.com/a/1878983

  17. @amolith i'll try to contribute to the #vimtrick hashtag as soon as i learn new things.
    of course, it would be great if everybody tagged their most useful #vimtricks here!

  18. another useful #vimtrick i learnt today:

    q: how to toggle case of the character under the cursor?
    a: typing `~`

    vim.fandom.com/wiki/Switching_