跳到主要内容

· 阅读需 2 分钟

Lazyvim 自带的快捷键有时候不符合我的心意,直接绑定新的快捷键不一定会达到你想要 的效果,下面是我总结的如果disable默认快捷键的方法

粗暴方法

我会直接在绑定新的快捷键之前,删掉对应的已有的快捷键,但是这种方法并不总是有效

vim.keymap.del("n", "<leader>l", {})

Lsp 相关的快捷键

因为我想要把 gd 绑定到 Lspsaga 提供的功能上,所以需要先 Disable 掉 Lazyvim 自带的绑定

https://www.lazyvim.org/plugins/lsp#%EF%B8%8F-customizing-lsp-keymaps

这里可以理解为在 keys 这个自带的 array 里面 append 了一个 ele,这个 ele 会 disable 掉前面默认定义的快捷键

  {
"neovim/nvim-lspconfig",
init = function()
local keys = require("lazyvim.plugins.lsp.keymaps").get()
-- disable a keymap
keys[#keys + 1] = { "gd", false }
end,
},

其他插件默认的快捷键

https://www.lazyvim.org/configuration/plugins#%EF%B8%8F-customizing-plugin-specs

以 Flash 为例, 我需要把 S 在 visual 模式下作为 surround 插件的快捷键,但是Flash 现在会使用这个快捷键,所以需要先 Disable 掉它

keys = {
...
{ "S", false, mode = { "v" } }, -- https://github.com/folke/flash.nvim/discussions/251
}
}

Debug 查看已有快捷键以及定义位置

:verbose map

· 阅读需 1 分钟

Hi there,

这是我的第一篇 blog, 好久好久之前就说用 docusaurus 搞个 blog, 今天终于行动了

非常简单,有空给大家分享下怎么弄这个东西

· 阅读需 3 分钟

config: https://github.com/LintaoAmons/CoolStuffes/blob/main/ideavim/.ideavimrc

视频讲解: https://www.bilibili.com/video/BV115411X7i4

" ================================================================================================
" = Extensions =====================================
" ================================================================================================
Plug 'tpope/vim-surround'
Plug 'preservim/nerdtree'
Plug 'terryma/vim-multiple-cursors'
map mc <A-n>
map mx <A-x>
map mv <A-p>

" ================================================================================================
" = Basic settings =====================================
" ================================================================================================
set clipboard+=unnamed
set ignorecase
set scrolloff=30
set history=200

set number
set relativenumber

set incsearch
set hlsearch
set keep-english-in-normal

" ================================================================================================
" = No Leader Keymaps =====================================
" ================================================================================================
nmap ge <action>(GotoNextError)
nmap gt <action>(GotoTest)
nmap gm <action>(MethodUp)
" last changed in current buffer(file)
nmap ga <action>(GotoImplementation)

" bookmark
nmap ma <action>(ToggleBookmark)

nmap L <action>(NextTab)
nmap H <action>(PreviousTab)


" ================================================================================================
" = Leader Keymaps =====================================
" ================================================================================================
" leaderkey
let mapleader=" "

" ================================================================================================
" 👻👻👻 Which-Key 👻👻👻
" ================================================================================================
set which-key
set notimeout

" d: diff
nmap <leader>dd <action>(Vcs.ShowTabbedFileHistory)

" f: Find/Format ⭐️
let g:WhichKeyDesc_FindOrFormat = "<leader>f FindOrFormat"
let g:WhichKeyDesc_FindOrFormat_FindFile = "<leader>ff FindFile"
nmap <leader>ff <action>(GotoFile)

let g:WhichKeyDesc_FindOrFormat_FindFileLocation = "<leader>fl FindFileLocation"
nmap <leader>fl <action>(SelectInProjectView)

let g:WhichKeyDesc_FindOrFormat_FindText = "<leader>ft FindText"
nmap <leader>ft <action>(FindInPath)

let g:WhichKeyDesc_FindOrFormat_Commands = "<leader>fc Commands"
nmap <leader>fc <action>(GotoAction)

let g:WhichKeyDesc_FindOrFormat_OpenedProject = "<leader>fp OpenedProject"
nmap <leader>fp <action>(OpenProjectWindows)

let g:WhichKeyDesc_FindOrFormat_Format = "<leader>fm Format"
nmap <leader>fm <action>(ReformatCode) \| <action>(OptimizeImports)

" g: Git ⭐️
let g:WhichKeyDesc_Git = "<leader>g Git"
let g:WhichKeyDesc_Git_RollbackHunk = "<leader>gr RollbackHunk"
nmap <leader>gr :action Vcs.RollbackChangedLines<CR>

" i: Insert ⭐️
let g:WhichKeyDesc_InsertAfterBrackets = "<leader>i InsertAfterBrackets"
nmap <leader>i f(a

" j: add Semicolon and goto nextline⭐️
let g:WhichKeyDesc_InsertSemicolon = "<leader>j InsertSemicolon"
nmap <leader>j A;<ESC>o

" l: lsp: Language server protocol (align with neovim)⭐️
let g:WhichKeyDesc_LSP = "<leader>l LSP"
let g:WhichKeyDesc_LSP_Rename = "<leader>lr Rename"
nmap <leader>lr <action>(RenameElement)


" n: No ⭐️
let g:WhichKeyDesc_No_Highlight = "<leader>nl NoHighlight"
nmap <leader>nl :nohlsearch<CR>


" s: Show ⭐️
let g:WhichKeyDesc_Show = "<leader>s Show"
let g:WhichKeyDesc_Show_FileStructure = "<leader>ss ShowFileStructure"
nmap <leader>ss <action>(FileStructurePopup)
let g:WhichKeyDesc_Show_Bookmarks = "<leader>sb ShowBookmarks"
nmap <leader>sb <action>(ShowBookmarks)
let g:WhichKeyDesc_Show_ParameterInfo = "<leader>sb ShowParameterInfo"
nmap <leader>sp <action>(ParameterInfo)

" r: Run/Re ⭐️
let g:WhichKeyDesc_RunOrRe = "<leader>r RunOrRe"
let g:WhichKeyDesc_RunOrRe_ReRun = "<leader>rr ReRun"
nmap <leader>rr <action>(Rerun)
let g:WhichKeyDesc_RunOrRe_ReRunTests = "<leader>rt ReRunTests"
nmap <leader>rt <action>(RerunTests)
let g:WhichKeyDesc_RunOrRe_Rename = "<leader>rn Rename"
map <leader>rn <action>(RenameElement)

" w: Window ⭐️
let g:WhichKeyDesc_Windows = "<leader>w Windows"
let g:WhichKeyDesc_Windows_maximize = "<leader>wo maximize"
nmap <leader>wo <action>(UnsplitAll) \| <action>(HideAllWindows)
let g:WhichKeyDesc_Windows_splitWindowVertically = "<leader>wl splitWindowVertically"
nmap <leader>wl <action>(Macro.SplitVertically)
let g:WhichKeyDesc_Windows_closeActiveWindow = "<leader>wc closeActiveWindow"
nmap <leader>wc <c-w>c

" z: zip(fold) ⭐️
let g:WhichKeyDesc_Zip = "<leader>z Zip"
let g:WhichKeyDesc_Zip_unZipAll = "<leader>zo unZipAll"
nmap <leader>zo <action>(ExpandAllRegions)
let g:WhichKeyDesc_Zip_ZipAll = "<leader>zc ZipAll"
nmap <leader>zc <action>(CollapseAllRegions)

" c: Close ⭐️;
let g:WhichKeyDesc_CloseBuffer = "<leader>c CloseBuffer"
nmap <leader>c :q!<CR>

" e: Toggle Explorer ⭐️
let g:WhichKeyDesc_ToggleExplorerOrExtract = "<leader>e ToggleExplorer"
nmap <leader>e <action>(ActivateProjectToolWindow)
" e: Extract
" extract method/function
vmap <leader>em <action>(ExtractMethod)
" extract constant
vmap <leader>ec <action>(IntroduceConstant)
" extract field
vmap <leader>ef <action>(IntroduceField)
" extract variable
vmap <leader>ev <action>(IntroduceVariable)

· 阅读需 1 分钟

https://github.com/rvaiya/warpd

我的配置

  • 触发 warpd

    • ctrl+cmd+': 触发 warpd
    • option+cmd+h:触发 warpd with hints
  • hjkl:移动指针

  • m:左键点击

  • >:右键点击

  • e:向下滚动

  • r:向上滚动

  • a: 加速移动

  • d: 减速移动

  • v: 在正常模式下,Toggle 拖拽模式(选文本,截图时会用)

  • s:在正常模式下,切换指针到另一个屏幕

  • f:在正常模式下,快速跳转

  • warpd --list-options 查看全部可配置项

· 阅读需 2 分钟
  1. [] 方括号索引器:

    • 通常用于根据列标签选择列。
    • 也可以用于选择行,但这通常是通过传递一个布尔序列或布尔条件来实现的,而不是直接通过行标签。

    示例:

    df['column_name']  # 选择名为 'column_name' 的列
    df[['column1', 'column2']] # 选择 'column1' 和 'column2' 这两列
    df[df['column'] > 10] # 根据布尔条件选择行
  2. .loc[] 方法:

    • 基于标签进行索引。
    • 可以用于同时选择行和列。
    • 行标签和列标签都需要明确指定。

    示例:

    df.loc[5, 'column_name']  # 选择索引标签为 5 的行和名为 'column_name' 的列的单个值
    df.loc[0:5, 'column_name'] # 选择索引标签从 0 到 5 的行和 'column_name' 列
    df.loc[:, 'column_name'] # 选择所有行的 'column_name' 列
  3. .iloc[] 方法:

    • 基于位置进行索引。
    • 也可用于同时选择行和列。
    • 使用整数索引来指定行和列的位置。

    示例:

    df.iloc[5, 2]  # 选择第 6 行和第 3 列的单个值
    df.iloc[0:5, 2] # 选择第 1 到第 5 行和第 3 列
    df.iloc[:, 2] # 选择所有行的第 3 列

总结:[] 方括号索引器主要用于选择列,而 .loc[].iloc[] 方法则可以用于根据行标签或列标签(.loc[])或根据行列的位置(.iloc[])来选择行和列。