預覽
依賴 neovim/neovim: Vim-fork focused on extensibility and usability (github.com)
Windows
winget install Neovim.Neovim
Homebrew on macOS or Linux
brew install neovim
安裝Nvim的開發版本:
brew install --HEAD neovim
更新Nvim的開發版本:
brew upgrade neovim --fetch-HEAD
linux or mac 編譯安裝
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage
如果 ./nvim.appimage
執行失敗, 試試:
./nvim.appimage --appimage-extract
./squashfs-root/AppRun --version
# Optional: exposing nvim globally.
sudo mv squashfs-root /
sudo ln -s /squashfs-root/AppRun /usr/bin/nvim
nvim
CentOS 8 / RHEL 8
Neovim is available through EPEL (Extra Packages for Enterprise Linux)
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y neovim python3-neovim
Clear Linux OS
Neovim is available through the neovim bundle
sudo swupd bundle-add neovim
source: github.com/congyukun/nvim
- create folder
mkdir -p ~/.config/nvim && cd ~/.config/nvim && git clone https://github.com/congyukun/nvim.git
- Go to directory
cd ~/.config/nvim/lua/plugins
- nvim edit plugins-setup.lua
nvim plugins-setup.lua
- install plugins
<esc> :w
- wait a moment
快捷鍵
vim.g.mapleader = " "
local keymap = vim.keymap
-- <CR> = enter
-- ---------- 插入模式 insert ---------- ---
keymap.set("i", "kk", "<ESC>")
keymap.set("i", "<leader>q", "<ESC>:q!<CR>")
keymap.set("i", "<leader>wq", "<ESC>:wq<CR>")
keymap.set("i", "<leader>w", "<ESC>:w!<CR>")
-- 跳到行首行尾 Jump to the end of the first line
keymap.set('i', '<C-h>', '<Esc>I', opt)
keymap.set('i', '<C-l>', '<Esc>A', opt)
-- ---------- 視覺模式 Visual ---------- ---
-- 單行或多行移動 Single-line or multi-line movement
keymap.set("v", "<leader>j", ":m '>+1<CR>gv=gv")
keymap.set("v", "<leader>k", ":m '<-2<CR>gv=gv")
-- ---------- 正常模式 Normal---------- ---
-- 視窗
keymap.set("n", "<leader>d", "<C-w>v") -- 水平新增視窗 Horizontal new window
keymap.set("n", "<leader>D", "<C-w>s") -- 垂直新增視窗 Vertical new window
keymap.set("n", "<leader>sc", "<C-w>c", opt) -- sc 關閉當前分屏 Close current split screen (s = close)
keymap.set("n", "<leader>so", "<C-w>o", opt) -- so 關閉其他分屏 Close other split screens (o = other)
-- Alt + hjkl 在視窗之間跳轉 Jump between windows
keymap.set('n', '<C-h>', '<C-w>h', opt)
keymap.set('n', '<C-j>', '<C-w>j', opt)
keymap.set('n', '<C-k>', '<C-w>k', opt)
keymap.set('n', '<C-l>', '<C-w>l', opt)
-- 取消高亮 Unhighlight
keymap.set("n", "<leader>nh", ":nohl<CR>")
-- 切換buffer change buffer
keymap.set("n", "<C-L>", ":bnext<CR>")
keymap.set("n", "<C-H>", ":bprevious<CR>")
-- ---------- plugins ---------- ---
-- nvim-tree
keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>")
-- <leader>t 開啟終端 create new Terminal
keymap.set('n', '<leader>t', ':sp | terminal<CR>', opt)
keymap.set('n', '<leader>T', ':vsp | terminal<CR>', opt)
-- <Esc> 退出終端 quit Terminal
keymap.set('t', '<Esc>', '<C-\\><C-N>', opt)
-- 終端視窗中進行視窗切換 Window switching in terminal window
keymap.set('t', '<C-h>', [[ <C-\><C-N><C-w>h ]], opt)
keymap.set('t', '<C-j>', [[ <C-\><C-N><C-w>j ]], opt)
keymap.set('t', '<C-k>', [[ <C-\><C-N><C-w>k ]], opt)
keymap.set('t', '<C-l>', [[ <C-\><C-N><C-w>l ]], opt)
-- H 移動到行首(Move to the beginning of the line),L 移動到行尾(Move to end of line)
keymap.set('n', 'H', '^', opt)
keymap.set('n', 'L', 'g_', opt)
-- 上下滾動瀏覽(Scroll up and down)
keymap.set('n', '<C-U>', '4j', opt)
keymap.set('n', '<C-D>', '4k', opt)
-- 修改 Ctrl-u 和 Ctrl-d 的移動幅度 從預設的移動半瓶改為移動 9 行
keymap.set('n', '<C-u>', '9k', opt)
keymap.set('n', '<C-d>', '9j', opt)
-- 退出 quit
keymap.set('n', 'q', ':q<CR>', opt)
keymap.set('n', 'qq', ':q!<CR>', opt)
keymap.set('n', 'Q', ':qa!<CR>', opt)
本作品採用《CC 協議》,轉載必須註明作者和本文連結