Skip to content

Latest commit

 

History

History
187 lines (154 loc) · 3.71 KB

File metadata and controls

187 lines (154 loc) · 3.71 KB

Neovim/Vim Tips & Tricks

A guide for editing, navigation, plugins, and Verilog workflows.


Table of Contents

  1. File Operations
  2. Navigation
  3. Splits & Tabs
  4. Search & Replace
  5. Commenting
  6. Verilog-Specific
  7. Plugins
  8. Diff Tools
  9. Clipboard

File Operations

Create/Save Files

:enew                 " Create new buffer  
:w filename.txt       " Save as filename.txt  
:wq or :x             " Save and quit  
:q!                   " Quit without saving  

Open Existing Files

:e path/to/file.txt   " Open file in current buffer  
:Ex                  " Open file explorer  

Navigation

Basic Movement

h, j, k, l            " Left, Down, Up, Right  
w, b                  " Next/previous word  
0, $                  " Start/end of line  
gg, G                 " Top/bottom of file  
Ctrl + u, Ctrl + d    " Half-page up/down  

Jump to Definitions

gd                    " Go to definition (LSP)  
Ctrl + ]              " Jump to tag (ctags)  
gr                    " Find references (LSP)  

Fuzzy Search

(Requires Telescope)

:Telescope find_files " Search files  
:Telescope live_grep  " Search text in files  

Splits & Tabs

Window Splits

:sp file.txt          " Horizontal split  
:vsp file.txt         " Vertical split  
Ctrl + w + h/j/k/l    " Move between splits  
Ctrl + w + c          " Close split  

Tabs

:tabnew file.txt      " Open in new tab  
gt, gT                " Next/previous tab  

Search & Replace

/pattern              " Search forward  
?pattern              " Search backward  
n, N                  " Next/previous match  
:%s/old/new/g         " Replace all  

Commenting

Built-in

:s/^/\/\/             " Comment line (Verilog)  
:s/^\/\///            " Uncomment  

Plugins

  • Comment.nvim:
    gcc                  " Toggle line comment  
    gbc                  " Toggle block comment  
  • vim-commentary:
    gcc                  " Toggle comment  

Verilog-Specific

LSP Setup

-- init.lua  
require('lspconfig').verible.setup{}  

Keymaps:

  • gd: Go to definition
  • K: Hover documentation

Tags Navigation

ctags -R --languages=verilog  " Generate tags  
Ctrl + ]              " Jump to tag  

Waveform Debugging

:!gtkwave waveform.vcd  

Plugins

Essential Plugins

-- Packer.nvim  
use {  
  'numToStr/Comment.nvim',       " Commenting  
  'nvim-telescope/telescope.nvim', " Fuzzy search  
  'sindrets/diffview.nvim',      " Diff tools  
}  

Diff Tools

Built-in Diff

nvim -d file1.v file2.v  

Commands:

]c, [c               " Next/previous diff  
:diffupdate          " Refresh diff  

Diffview.nvim

:DiffviewOpen file1.v file2.v  

Clipboard

Pasting in Neovide

  • Ctrl + Shift + V: Paste from system clipboard.
  • "+p: Paste from Neovim’s clipboard.

Fix Clipboard

sudo apt install xclip  # Linux  

Pro Tips

  • Reload Config: :luafile %
  • Check Filetype: :set ft?
  • Custom Keymaps: Add to init.lua:
    vim.keymap.set('n', '<leader>ff', ':Telescope find_files<CR>')  

Enjoy your Neovim journey! 🚀