Skip to content

Vim / NeoVim

vim

Motion

Key(s)Bidding
iinsert
aappend
oinsert at next line
Oinsert at previous line
uundo
wNext word
bPrevious word
eNext end of the word
WNext whitespace
fFind next character
FFind previous character
tFind before next character
TFind before previous character
ggfirst line of the file
Glast line of the file
%Go to start / end if block
^Go to first character of line
$Go to end of line
0Go to start of line
pPaste
dDelete
rReplace 1 character
RReplace multiple characters
yYank / Copy
vVisual mode
VVisual mode (line)
Ctrl + vVisual mode (block)
vi + ' or " or ( or { or [ or <select all within scope
va + ' or " or ( or { or [ or <select all within scope (inclusive)
Ctrl + dScroll down
Ctrl + uScroll up
Ctrl + rRedo
di(Delete all in parenthesis
ci(Change all in parenthesis

Macro

  1. q[register] = start recording to register. Example: qa
  2. Do whatever
  3. q to stop
  4. @[register] = replay macro. Example @a

Note: @@ Replay last macro 100@a Run macro a 100 times/

Pane

Control + W

Key(s)Bidding
vVertical pane
sHorizontal pane
h / j / k / lMove to pane
left / right / up / downMove to pane
H / J / K / KMove pane to direction
+Increase height
-Decrease height
<Increase width
>Decrease width
=Equal height and width
cClose current pane
oQuit all except current
_Minimize all except current

config

Vim default setting

set tabstop=2 shiftwidth=2 expandtab relativenumber foldmethod=indent autoindent hlsearch incsearch
filetype plugin indent on
" colorscheme Monokai
syntax on

NeoVim

Setup

  1. create ~/.config/nvim/init.lua Put all the plugin in ~/.config/nvim/lua/plugin.lua or Put all the plugin in ~/.config/nvim/lua/plugins/some-plugin.lua

add the config at

lua
config = function() 
  -- do something here
end
  1. Set vim parameters
lua
vim.cmd("set expandtab")
vim.cmd("set tabstop=2")
vim.cmd("set softtabstop=2")
vim.cmd("set shiftwidth=2")

-- map leader to space
vim.g.mapleader = " "

vim.keymap.set('n', '<C-s>', ':w<CR>', { noremap = true, silent = true })
vim.keymap.set('i', '<C-s>', '<Esc>:w<CR>a', { noremap = true, silent = true })
vim.keymap.set('n', '<C-t>', ':tabnew<CR>', { noremap = true, silent = true })
  1. Setup lazy vim. Copy from lazy.nvim
  2. Install telescope. Telescope and configure https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#usage
  3. Install treesitter
  4. Instal neotree
  5. Install Mason, Mason-lspconfig, nvim-lspconfig
  6. Telescope-ui-select
  7. None-ls (this might not needed)

Directory specific config

To have specific config on project based feature(s), add .nvim.lua in the project root Example of the config file

lua
-- Project-Specific Config Example

-- Set project-specific options

vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true

-- Add keybindings specific to the project
vim.keymap.set('n', '<leader>pr', ':!npm run dev<CR>', { noremap = true, silent = true })

-- Configure plugins
if require('telescope') then
  require('telescope').setup({
    defaults = {

      file_ignore_patterns = { "node_modules", "dist/" }
    }
  })
end

print("Loaded project-specific Neovim config!")