Nir Lichtman youtube video tips
Why vim
See this video on why Nir prefers vim to IDE's
- more efficient in what you can do from the keyboard
- autocomplete can use a language server
- scrolling to line:
%takes you to end of function; 0,^,$to go to start, first char, end of line;/and?: search- 'f' and 'F': find in line
1
source: this youtube video
| C-n | complete word |
| C-x l | complete line |
In a terminal
| C-w | to allow you to use a vim command, e.g. C-w :... |
2
This youtube video And this youtube video
| gj,gk | move up/down within wrapped lines |
copen
:grep hello *.txt
:copen
3
From this youtube video
4
:set ignorecaseto ignore case when searching:set smartcasecase sensitive if uppercase letters present (see:help smartcase)
5
$ 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.)
- Close a window with
C-w qto close the window but not the buffer whereas:qcloses window and closes the buffer if it is the last window with that buffer. :bufdo g/function/ddoes this command on all open buffers
7
From here. How to delete without copying:
:regshows registers- vim copies to default reg automatically when deleting
- There is a black hole register:
"_dto delete without copying - named registers:
"ay, or"qd.
Opening files
| gf | open file under cursor |
| C-w f | open file under cursor in new window |
Basic Stuff
Regex Search Replace
- Append to line:
:s/$/hello; prepend to line::s/^/hello; - 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) - Append to
hellousing 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