侧边栏壁纸
  • 累计撰写 52 篇文章
  • 累计创建 0 个标签
  • 累计收到 39 条评论

目 录CONTENT

文章目录

About LazyVim

what mean n,i,c,v,x etc of Mode in lazyvim?

Let me explain the different modes in Vim/LazyVim:

n (Normal Mode)

  • This is the default mode you start in
  • Used for navigation and executing commands
  • You can enter this mode from any other mode by pressing Esc
  • In this mode, keystrokes are interpreted as commands rather than text input

x (Visual Mode)

  • Used for selecting and manipulating blocks of text
  • There are actually three types of visual mode:
    1. v - Character-wise visual mode (select characters)
    2. V - Line-wise visual mode (select entire lines)
    3. Ctrl+v - Block-wise visual mode (select rectangular blocks)

Other important modes include:

  • i (Insert Mode) - For typing/inserting text
  • R (Replace Mode) - For replacing existing text
  • c (Command Mode) - Entered by typing : in normal mode

To see which mode you’re currently in, look at the bottom left of your LazyVim window. It will show:

  • NORMAL for normal mode
  • VISUAL for visual mode
  • INSERT for insert mode
  • COMMAND for command mode
Command\Mode Normal Insert Command-line Visual Select Operator-pending Terminal Lang-Arg
[nore]map yes - - yes yes yes - -
n[nore]map yes - - - - - - -
[nore]map! - yes yes - - - - -
i[nore]map - yes - - - - - -
c[nore]map - - yes - - - - -
v[nore]map - - - yes yes - - -
x[nore]map - - - yes - - - -
s[nore]map - - - - yes - - -
o[nore]map - - - - - yes - -
t[nore]map - - - - - - yes -
l[nore]map - yes yes - - - - yes

注:You can found it: :help map-table

(map-table in map.txt)

vim shortcut

Here are some essential Vim shortcuts to help you navigate and edit efficiently:

Basic Navigation (Normal Mode)

  • h j k l - Move left, down, up, right
  • w - Jump to start of next word
  • b - Jump to start of previous word
  • 0 - Jump to start of line
  • $ - Jump to end of line
  • gg - Go to first line
  • G - Go to last line
  • {number}G - Go to specific line number

Editing (Normal Mode)

  • i - Insert mode before cursor
  • a - Insert mode after cursor
  • o - Insert new line below
  • O - Insert new line above
  • dd - Delete current line
  • yy - Copy (yank) current line
  • p - Paste after cursor
  • u - Undo
  • Ctrl + r - Redo

Visual Mode

  • v - Enter visual mode (for selecting text)
  • V - Select entire lines
  • Ctrl + v - Visual block mode

Search and Replace

  • /pattern - Search forward
  • ?pattern - Search backward
  • n - Next occurrence
  • N - Previous occurrence
  • :%s/old/new/g - Replace all occurrences

Save and Quit

  • :w - Save
  • :q - Quit
  • :wq or :x - Save and quit
  • :q! - Quit without saving

LazyVim Specific

  • Space - Leader key
  • Space + e - Toggle file explorer
  • Space + ff - Find files
  • Space + fg - Live grep
  • Space + / - Search in current buffer
  • gc - Comment/uncomment lines
  • Ctrl + / - Toggle terminal

Multiple Windows

  • Ctrl + w + v - Split vertically
  • Ctrl + w + s - Split horizontally
  • Ctrl + w + h/j/k/l - Navigate between windows

how to chage brew mirrors on macOS?

To change Homebrew’s download source (mirrors) on macOS, you can use the following steps:

  1. View current brew source:

    brew doctor
    
  2. Popular mirrors you can use:

    • Official GitHub Mirror (Default, generally good worldwide):

      export HOMEBREW_BREW_GIT_REMOTE="https://github.com/Homebrew/brew.git"
      export HOMEBREW_CORE_GIT_REMOTE="https://github.com/Homebrew/homebrew-core.git"
      
    • USTC (China):

      export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
      export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
      
    • Tsinghua University (China):

      export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
      export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
      
  3. Make the change permanent: Add the export commands to your shell configuration file (~/.zshrc for Zsh or ~/.bash_profile for Bash):

    echo 'export HOMEBREW_BREW_GIT_REMOTE="your-chosen-mirror-url"' >> ~/.zshrc
    echo 'export HOMEBREW_CORE_GIT_REMOTE="your-chosen-mirror-url"' >> ~/.zshrc
    
  4. Run:

    source ~/.zshrc  # or source ~/.bash_profile
    brew update-reset
    brew update
    
  5. After changing the mirror, you should see faster download speeds when installing or updating packages if you’ve chosen a mirror that’s geographically closer to you.

    Note: If you want to revert to the official source, you can remove the export commands from your shell configuration file and run the update-reset command again.

how to set proxy in Lazyvim?

To set up a proxy in LazyVim, you have several options:

System-wide Git Proxy (Recommended):

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

In LazyVim Configuration: Create or edit ~/.config/nvim/lua/config/options.lua and add:

-- Set proxy for network operations
vim.g.proxy = 'http://127.0.0.1:7890'

For Mason Package Manager: Edit ~/.config/nvim/lua/config/lazy.lua and add:

{
  "williamboman/mason.nvim",
  opts = {
    -- Add proxy settings to mason
    proxy_url = "http://127.0.0.1:7890",
  },
}

For Neovim’s built-in LSP: Add to your ~/.config/nvim/lua/config/options.lua:

vim.env.http_proxy = 'http://127.0.0.1:7890'
vim.env.https_proxy = 'http://127.0.0.1:7890'

Notes:

  • Replace 7890 with your actual proxy port
  • Common proxy ports are: 7890 (Clash), 1080 (SOCKS5), 8080 (HTTP)
  • After making changes, restart Neovim for the settings to take effect
  • You might need to run :Mason and :MasonUpdate to verify the proxy settings are working

To remove the proxy settings:

git config --global --unset http.proxy
git config --global --unset https.proxy

Remember to adjust the proxy address and port according to your specific proxy setup (e.g., if you’re using a different proxy service or port).

how to set shortcut of Insert Mode in Lazyvim?

To set shortcuts for Insert Mode in LazyVim, you can modify or add keymaps in your configuration. Here’s how to do it:

Edit Keymaps File: Create or edit ~/.config/nvim/lua/config/keymaps.lua:

-- Basic cursor movement in Insert Mode
vim.keymap.set('i', '<C-h>', '<Left>', { desc = 'Move left' })
vim.keymap.set('i', '<C-j>', '<Down>', { desc = 'Move down' })
vim.keymap.set('i', '<C-k>', '<Up>', { desc = 'Move up' })
vim.keymap.set('i', '<C-l>', '<Right>', { desc = 'Move right' })

-- Word movement in Insert Mode
vim.keymap.set('i', '<C-b>', '<C-Left>', { desc = 'Move word backward' })
vim.keymap.set('i', '<C-w>', '<C-Right>', { desc = 'Move word forward' })

-- Line movement in Insert Mode
vim.keymap.set('i', '<C-e>', '<End>', { desc = 'Move to line end' })
vim.keymap.set('i', '<C-a>', '<Home>', { desc = 'Move to line start' })

-- Delete operations in Insert Mode
vim.keymap.set('i', '<C-d>', '<Delete>', { desc = 'Delete forward' })
vim.keymap.set('i', '<C-BS>', '<C-w>', { desc = 'Delete word backward' })

-- Other useful Insert Mode mappings
vim.keymap.set('i', '<C-u>', '<C-g>u<C-u>', { desc = 'Delete to start of line' })
vim.keymap.set('i', '<C-y>', '<Esc>pa', { desc = 'Paste in insert mode' })

Syntax Explanation:

vim.keymap.set({mode}, {lhs}, {rhs}, {opts})
-- mode: 'i' for Insert Mode
-- lhs: the key combination you press
-- rhs: the action to perform
-- opts: additional options like description

Common Options:

local opts = {
    desc = "Description of the mapping",
    silent = true,     -- Don't show command in command line
    noremap = true,    -- Don't use recursive mapping
    expr = false,      -- Expression mapping
    buffer = nil       -- Buffer local mapping
}

Check Existing Mappings:

  • In Normal mode, type :map to see all mappings
  • Use :verbose imap to see Insert mode mappings and where they were set

Remove Mappings:

-- Remove a mapping
vim.keymap.del('i', '<C-h>')

Remember:

  • Test your mappings after setting them
  • Avoid overriding essential functionality
  • Use :checkhealth to check for conflicts
  • Add descriptions for better documentation
  • Use <Cmd> instead of : for command mappings in Insert mode

After making changes, restart Neovim or source the config file:

:source ~/.config/nvim/lua/config/keymaps.lua

Caused by SSLError

Q: Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)’))) - skipping

A:

# Download certificates
curl https://curl.se/ca/cacert.pem -o ~/cacert.pem

# Set the SSL certificate path
export SSL_CERT_FILE=~/cacert.pem
export REQUESTS_CA_BUNDLE=~/cacert.pem
0

评论区