Skip to content

Instantly share code, notes, and snippets.

@matyklug18
Created February 17, 2022 11:22
Show Gist options
  • Save matyklug18/1c295114def1928f13d3e3dc1f61bf59 to your computer and use it in GitHub Desktop.
Save matyklug18/1c295114def1928f13d3e3dc1f61bf59 to your computer and use it in GitHub Desktop.

Synopsis

A quite common thing I see beginners do is put as many plugins as possible into their vim config.

I don't blame them, I did that too.

However, even vanilla vim is extremely capable.

NOTE: When I say vim, I refer to NeoVim, because I firmly believe it's the replacement for Vim.

In this blog post, I want to share a few tips and tricks I use to get features you normally have plugins do.

Tips

The K (Shift+K) shortcut in normal mode opens the word under the cursor in vim's builtin manpage viewer. Very useful for writing C.

The shortcut (Control+X) in insert mode enters Completion (^X) mode, which can then be followed by another key with Ctrl pressed, such as

  • <C-p> for completing previously typed words
  • <C-j> for completing tags
  • <C-f> for completing file paths

The <C-n> shortcut completes keywords, such as function definitions or variables. It is not a part of ^X mode. Searches path.

The # shortcut in normal mode searches for the previous occurence of the word under the cursor.

If you set list, you can use the set listchars setting to highlight characters such as tabs, trailing spaces...

Vim can read the tags file generated by the ctags utility, which can generate tags for codebases, and allow stuff like goto definition and completion to be more context-aware in different languages.

The gf (Goto File) shortcut searches for a file in the path setting. Can be for example used to goto to header files if path is appropriately set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment