Table of contents
LazyVim and tmux
This is how my entire setup looks like.
- I do have a next js project opened on the left side with 4 sessions
runDev
for staring and installing dependenciesCodeHere
for writing codelazygit
for managing vcszsh
another window.
- In the top right there’s a java leetcode question ( I suck at DSA)
- in the below another pane opened.
Neovim, aka Nvim, is a highly extensible text editor well-suited for terminal-based text editing tasks. It inherits many features from its predecessor, Vim, while adding enhancements and improving usability.
Now what is LazyVim?
- LazyVim is Neovim setup powered by
lazy.nvim
Benefits
- Insanely fast 🚀 and efficient in executing commands and editing text📝.
- Highly customizable🛠️. Thanks to plugins.
- Navigate🧠and edit your code without exiting terminal.
Few Prerequisites
- Basic knowledge of CLI.
- nerd font installed.
- ‣
- Make your boring terminal look cool.
- Basic Vim commands
- Though there’s a heavy learning curve it’s just worth it. I know coming out of
VS code
is hard :’) - There are essentially 3 modes
normal
,visual
and `
VIMÂ or Vi Improved, is a free and open-source text editor for the terminal.
Here are few commands to learn VIM.
Vim Commands
1.) gg - go to the top of the page
2.) G - go to the bottom of the page
3.) 0 - go to the starting of the line even if spaces are there it goes to the atmost start of the line
** ^ - go to the start of the line where words begin
4.) $ - go to the end of the line
4.) w- go to the first character of the next word
5.) e - go to the end character of the next word
6.) b - go to the first character of the previous word
7.) W, E, B - does the same work as the above commands but skips the other characters and traverses through words only
8.) / - forward search
9.) ? - backward search
10.) h(<-), l(->)
11.) j(down), k(up)
12.) dd - delete entire line
13.) dw - delete word
** Number* dw => delete N number of words
14.) d$ - delete till the end of the line from the cursor
*** d^ - deletes till the start of the line from the cursor
15.) p - paste
16.) yy - copy the entire line
17.) yw - copy the word
18.) y$ - copy till the end of the line from the cursor
******19.) :%s/wordtobepalced/replacingword/g - entire document changes (if we use gc in the end it asks for y or n for every instance)
20.) :form,to s/ wordtobepalced/replacingword/g - certain number of lines
21.) ctrl+ V - select over a certain area
22.) V - select over line
23.) x - delete character
24.) s- delete character and goes to insert mode
25.) r - replace text
26.) c- change -> goes to the insert mode deleting that word
27.) c$ => deletes from cursor and goes to insert mode
28.] cw => deletes that word and goes to insert mode
29.) n - goes to the next instance of the word
30.) N - goes to the previous instance of the word
31.) f - followed by character => moves till the next character is found
32.) F - same as above but reverse search
33.) H - goes to the top of the visible screen
34.) L - goes to the bottom of the visible screen
35.) M - goes to the mid of the visible screen
36.) ctrl + enter => create a new line
37.) ddp - moves the line down
38.) ddkP - move line up
37.) ddp - moves the line down
38.) yi” - copy inside double quotes
Huh!🤔 too many right! Don’t worry you gotta learn few first then everything will get handy. The best part is
you don't ever need a mouse 🦍
.Configuration
- My personal config files :- https://github.com/durgaprasad118/Dotfiles/
- the configuration is pretty simple and stright forward as explained here ‣
- Plugins are highly customizable and can look at my dotfiles for further info.
Usage
- Go to your required directory and type
nvim
that’s it, you are good to write your code now.
- Here are few commands you can pay a visit although documentation has everything.
neovim commands
- sf (n) _ telescope in root dir
- ;r - search word
- \\ - open all buffers
- rn - file rename
- ctrl + R -redo
- jk(i)_ moves to normal mode
- leader + e ⇒ file explorer
- TODO: (xyz) in file
- leader + s + t ⇒ searches for all todos
- ctrl + n ⇒ moves down in suggestions
- ctrl + p ⇒ moves up in suggestions
- gd _ go to definintion ( we can click on import to go where it was defined)
- :bd - close tab
- ss - hori pane
- sv - vertical split
- shift + (h,l,jk) movemnts to the tabs
- ctrl + (h,l,j,k) movements to panes
- leader + r + c ⇒ ICE rename
- leader + R ⇒ rename all
- o ⇒ new line down
- O ⇒ new line up
- p ⇒ paste down
- P ⇒ paste up
- shift + k ( in visual mode ) ⇒ moves line up and same for ( shift + j ) down
- leader + xx ( shows diagnostics)
- leader + c ⇒ code actions
- importing organizing
- remove unused imports
- leader + b ⇒ buffers
- gcc ⇒ commenting
- ctrl + r ⇒ redo
- The best part is these are also customizable.
- This comes with
lazygit
which is a awesome place to make commits pull, push, check status, and do everything you need using git.
Tmux
- Now another thing comes up which is
tmux
(terminal multiplexer). - Persistent sessions: Detach and reattach sessions, ensuring your work is never lost
- Efficient window and pane management: Split your terminal into multiple windows and panes
- Improve productivity: Run multiple things within a single window.
Advantages
tmux
andneovim
can interact with easily together that the super power of it.
- This is also highly customisable and looks awesome like mine. ( I love my terminal)
- This is how my entire working environment looks like.
- The installation is pretty simple.
- Install tmux from:- https://github.com/tmux/tmux/wiki
- Create a
.tmux.conf
file in the root directory - Add :- https://github.com/tmux-plugins/tpm
- run this command
tmux source ~/.tmux.conf
Conclusion
It feels like confusing in the start while configuring LSP’s and managing sessions. Trust me I’ve gone through this and once you get over it you will enjoy the ride.
Step out of comfort zone and give it a try! I am sure you will fall in love with the power of tmux and lazyVim.
I will post a blog separately on both
lazyVim
and tmux
right from the scratch.Â