Dup Ver Goto 📝

Various Vim Tips

PT2/editor/vim/tips vim tips does not exist
To
110 lines, 513 words, 3452 chars Page 'VariousTips_001' does not exist.

Nir Lichtman youtube video tips

Why vim

See this video on why Nir prefers vim to IDE's

1

source: this youtube video

C-ncomplete word
C-x lcomplete line

In a terminal

C-wto allow you to use a vim command, e.g. C-w :...

2

This youtube video And this youtube video

gj,gkmove up/down within wrapped lines

copen

:grep hello *.txt
:copen

3

From this youtube video

4

See this youtube video

5

See this youtube video

$ ctags -R src
:tag *argedupe             # completion
C-]

6

This vim doesn't need tabs video You can use splits. (I use both tabs and splits.)

7

From here. How to delete without copying:

Opening files

gfopen file under cursor
C-w fopen file under cursor in new window

Basic Stuff

Regex Search Replace

  1. Append to line: :s/$/hello; prepend to line: :s/^/hello;
  2. Prepend to first non-whitespace without lookbehind: s/\(\S\)/hello\1; prepend to first non-whitespace char using lookahead: :s/\ze\S/hello (see here for info on lookahead/lookbehind; using lookbehind to append append to last non-whitespace :s/\s*\ze$/x (note that $ goes after the lookahead assertion)
  3. Append to hello using lookbehind: :s/hello\zs/ world

File Tree

In neovim, C-n opens the file tree. (I'm not sure whether that is standard or my default config.) Selecting a file with enter sends it to one of the open windows: if one window it will use that, if more than one, it enumerates them a,b,c and you press a letter for the window you want. Use a nerdfont if you want file and folder icons to work properly. I use Hack Nerdfont in both Konsole and Windows Terminal.

Various

Paste setting into buffer

:call setreg("+", getbufvar("%", "&guifont"))

and then "+p to paste.

Command Line History

:q         -- open command line history
C-c        -- copy command to command line (C-c again to exit)
C-c C-c    -- exit command line history

Accessing buffers from command line

Copying matched lines to a position

:g/pattern/t10

will copy all matching lines to position starting at line 10