kulifmor.com

Boosting Productivity with Neovim: Essential Tips and Tricks

Written on

Chapter 1: Introduction to Neovim Cheat Sheet

After dedicating the previous year to mastering Vim and Neovim, I wanted to share a collection of useful tips from my cheat sheet that significantly enhance my efficiency in Neovim.

Motions, Windows, & Editing

To navigate and edit effectively in Neovim, here are some essential commands:

  • Switch tabs: gt
  • Change pane: Ctrl+VIM_KEY
  • Rotate windows: Ctrl+W R
  • Adjust width: Ctrl+W < or >
  • Resize equally: Ctrl+W =
  • Resize vertically: Ctrl + w _ (for larger) or Ctrl + w | (for wider)
  • Swap vertical splits: Ctrl + x
  • Move window: Ctrl + w + VIM_KEY
  • Split buffer into a new tab: Ctrl+W T
  • Modify to end of line: C
  • Delete to end of line: D
  • Remove and edit line: cc
  • Delete contiguous lines and whitespace: dap
  • Delete contiguous lines only: dip
  • Capitalize visual selection: ~
  • Save and close buffer: ZZ
  • Close buffer without saving: ZQ

For deletion in insert mode:

  • Delete the previous character: Ctrl+h
  • Delete the previous word: Ctrl+w
  • Remove the entire line (excluding indent): Ctrl+u

To manage indentation:

  • Indent current line: Ctrl+t
  • Backindent current line: Ctrl+d

Centering the screen can be done with zz, and for macros:

  • Start recording: q
  • End recording: w
  • Apply macro: 3@w

For searching and jumping between marked locations:

  • Set a mark: mA
  • Jump to mark: 'A
  • Jump to mark with column: `` A `

To search for patterns in your file:

  • Search in current file: :vimgrep /asdf/ %
  • Search in current directory: :vimgrep /asdf/ **/*.rb

To enter visual block selection mode, use Ctrl+v.

Key Mappings for Enhanced Efficiency

Here are some custom key mappings to streamline your workflow:

  • Quickly exit insert mode with jj
  • Adjust the behavior of Y to function like C or D
  • Close a buffer with q
  • Retain split when closing a buffer: w

You can also navigate between quickfix and location list items with:

  • Forward quickfix: h
  • Backward quickfix: ;
  • Forward location list: k
  • Backward location list: j

To dismiss messages, use nd. Resize splits conveniently with arrow keys.

In visual mode:

  • Stay in indent mode with < and >gv
  • Move blocks up and down with J and K
  • Search for highlighted text with //

For terminal mode, you can auto-enter insert mode when opening a terminal.

Plugins and Extensions

To enhance your Neovim experience further, consider using plugins like Vim-unimpaired for improved navigation and Telescope for searching:

require("telescope").load_extension("fzf")

require("telescope").load_extension("live_grep_args")

You can set up key mappings for file searches and live grepping as shown in the original content.

Nvim-ufo for Code Folding

For managing code folds, you can set up the following:

vim.keymap.set('n', 'zR', require('ufo').openAllFolds, { desc = "Open all folds" })

Conclusion

If you're interested in my full configuration, feel free to explore my content! For more insights, check out my YouTube channel and consider subscribing for future updates!

The first video demonstrates the nvim-cheat.sh plugin, which integrates a cheatsheet with Neovim, enhancing your coding efficiency.

The second video provides a comprehensive cheat sheet for writing LaTeX in Neovim, making it a valuable resource for users looking to improve their document preparation skills.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Title: Managing Camera Timestamps for Organized Photo Libraries

Learn how to maintain camera timestamps to keep your photo library organized and avoid chaos when capturing memories.

A Journey Through Memory: A Post-Apocalyptic Tale

An educational sci-fi narrative exploring neural behavior and memory exchange in a dystopian setting.

# Exploring the Astonishing Atom Count in a Teaspoon of Water

Discover the mind-boggling number of hydrogen atoms in a teaspoon of water compared to the vastness of the oceans.