My Neovim and Tmux Shortcuts

Nov 4, 2024 - 3 minute read
feature image

There are lots of shortcuts in Neovim that I personally don’t remember like find and replace, rename variable for refactoring. Due to jumping around projct like Java and other project I sometimes switching between code editor and forgot about the shortcuts, this will help me at least in the future for my personal reference.

I’m finally using LazyVim as the main Plugin it includes a lots of plugins(recommended to read the source to know the plugins). One of the cool plugin to help for productivity is the which-key showing the keymaps just using <space>?, and if that’s not enough LazyVim provides the documentation for the all keymaps .

I’ve been using Neovim since a very long time, and this is My dotfiles. Please note that the shortcuts has been customize to my personal preference, so this is based on the dotfiles above. This shortcuts is heavily coming from craftzdog

tmux

This tools I used daily to open lots of terminal ctrl + s –> this is the prefix shortcuts for all of my tmux

Fresh Install

`I` ->  capital I install all plugins in .config.tmux

Terminal Creation

 `c` -> create new terminal tab
 `,` -> rename the current terminal tab
 `x` -> kill the current terminal tab
 `-` -> create new terminal on the right (current tab)
 `|` -> create new terminal on the bottom (current tab)

Cursor Movement

For the current tab

 `j` -> move up
 `k` -> move down
 `l` -> move right
 `h` -> move left

For tab movement

 `n` -> next tab
 `p` -> previous tab
 `0-9` -> choose index tab

Reszie Window

  • after prefix hold ctrl and press arrow up,down,left,right keyboard

NeoVim

This is the shortcuts for this branch

Exploration

- <space> + e -> open up folder explorer root project dir
- sf -> open up file browser in the current opened dir
  - c -> create new file or dir
  - a -> enter filename to filter files
- ;f -> find files by name
- ;r -> search text int the project dir

Editor

 te + enter -> create new tab
 <tab> and <shift><tab> -> switching tabs
 sv -> split window to the right
 ss -> split window to bottom
 <leader>gB -> open the current buffer and line in the browser(github.com or else)
 <leader>be -> list all the opened file (buffer) showing menu on the left

#add surrounding
v -> block the word/code first
gsa -> add '/" single or double quote or anything to surround the word/code
 Many basic things which I don't cover

Go

This shortcut will only work on .go file extension

\sr -> run the current program
\sb -> go build
\st-> running test
--ctrl + c -> show test coverage (temp not available)

html

zc -> close current tag
zl -> open current closed tag

Bookmark

To remember the position of the code and adding tag and description to it

\t -> open bookmark window
\z -> add bookmark to current project
\g -> add bookmark to all (can be opened from anywhere)

Git

<leader>gg -> openup LazyGit
<leader>gb -> git blame
<leader>gf -> git file history
<leader>gs -> git status
<leader>ge -> git status with explorer on the left

Refactoring

<leader> currently mapped to <space>

  • <leader>cr -> rename variable or function; Tested in .lua files it also rename the other files which calls the global function
  • <leader>sr -> open up new window buffer for find and replace using this plugin
    • type the text to replace with in the input text
    • to replace all use \ + r
    • to replace specific lines use \ + l the cursor needs to move to the specific shown text
    • open help use g + ? other shortcuts also appear on the menu