#vimtrick — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #vimtrick, aggregated by home.social.
-
-
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` -
nice #vimtrick:
:g/^#/#
when editing markdown, prints a ToC to jump to the header you want.
https://vimrcfu.com/snippet/165 -
#vimtrick
q: how to break a line at cursor position (and keep on normal mode)?
a: press "R" "Intro" "Esc" keys -
#vimtrick
q: how to scroll both files/windows at the same time?
a: `:set scrollbind` in both windows (`:set noscrollbind` to disable) -
#vimtrick
q: repeat last colon command
a: first `@:`, further repeats `@@` -
#vimtrick
q: how do i activate spellcheck in vim?
a: `:setlocal spell spelllang=es`q: how do i deactivate it?
a: `:setlocal spell!` -
#vimtrick
q: how do i jump to the next double-quote (")?
a: press `f"`, or `F"` to go backwards -
#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 -
#vimtrick
q: how do i resize a split window?
a: either write `:30winc >`, press "30" "Ctrl+W" ">" or write `:vertical resize 60` -
#vimtrick
q: how do i make the split windows size equal?
a: press "Ctrl+W" "=" -
#vimtrick
q: how to open a link under cursor with browser?
a: press `gx` -
#vimtrick
q: how to show the complete path of the actual file?
a: press "1" "Ctrl+G" -
#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) -
#vimtrick
q: what to do with code already written with tabs?
a: after setting the above, `:set retab` -
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` -
@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! -
another useful #vimtrick i learnt today:
q: how to toggle case of the character under the cursor?
a: typing `~`