Vim / NeoVim
vim
Motion
Key(s) | Bidding |
---|---|
i | insert |
a | append |
o | insert at next line |
O | insert at previous line |
u | undo |
w | Next word |
b | Previous word |
e | Next end of the word |
W | Next whitespace |
f | Find next character |
F | Find previous character |
t | Find before next character |
T | Find before previous character |
gg | first line of the file |
G | last line of the file |
% | Go to start / end if block |
^ | Go to first character of line |
$ | Go to end of line |
0 | Go to start of line |
p | Paste |
d | Delete |
r | Replace 1 character |
R | Replace multiple characters |
y | Yank / Copy |
v | Visual mode |
V | Visual mode (line) |
Ctrl + v | Visual mode (block) |
vi + ' or " or ( or { or [ or < | select all within scope |
va + ' or " or ( or { or [ or < | select all within scope (inclusive) |
Ctrl + d | Scroll down |
Ctrl + u | Scroll up |
Ctrl + r | Redo |
di( | Delete all in parenthesis |
ci( | Change all in parenthesis |
Macro
- q[register] = start recording to register. Example: qa
- Do whatever
- q to stop
- @[register] = replay macro. Example @a
Note: @@ Replay last macro 100@a Run macro a 100 times/
Pane
Control + W
Key(s) | Bidding |
---|---|
v | Vertical pane |
s | Horizontal pane |
h / j / k / l | Move to pane |
left / right / up / down | Move to pane |
H / J / K / K | Move pane to direction |
+ | Increase height |
- | Decrease height |
< | Increase width |
> | Decrease width |
= | Equal height and width |
c | Close current pane |
o | Quit 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
- 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
- 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 })
- Setup lazy vim. Copy from lazy.nvim
- Install telescope. Telescope and configure https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#usage
- Install treesitter
- Instal neotree
- Install Mason, Mason-lspconfig, nvim-lspconfig
- Telescope-ui-select
- 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!")