serpl
0.3.3
serpl
是一個終端使用者介面 (TUI) 應用程序,允許使用者搜尋和替換整個資料夾中的關鍵字,類似於 VS Code 中提供的功能。
cargo install serpl
cargo install serpl --features ast_grep
serpl
檢查發布頁面以獲取最新的二進位。
serpl
可以使用 Homebrew 安裝:
brew install serpl
可以使用pacman
從官方儲存庫安裝serpl
:
pacman -S serpl
serpl
自 24.11 起包含在 nixpkgs 中,並且可以透過 Nix 以不同方式安裝:
在獨立 Nix 設定上:
nix profile install nixpkgs#serpl
在 NixOS 上(透過configuration.nix
或類似的):
{ pkgs , ... } : {
environment . systemPackages = [ pkgs . serpl ] ;
}
在家庭管理器上:
{ pkgs , ... } : {
home . packages = [ pkgs . serpl ] ;
}
serpl
serpl --project-root /path/to/project
可以透過config.json
檔案自訂預設鍵綁定。
組合鍵 | 行動 |
---|---|
Ctrl + c | 辭職 |
Ctrl + b | 幫助 |
Tab | 在選項卡之間切換 |
Backtab | 切換到上一個選項卡 |
Ctrl + o | 處理所有文件的替換 |
r | 處理選定文件或行的替換 |
Ctrl + n | 切換搜尋和取代模式 |
Enter | 執行搜尋(對於大資料夾) |
g / Left / h | 轉到列表頂部 |
G / Right / l | 轉到列表底部 |
j / Down | 移至下一個項目 |
k / Up | 移至上一項 |
/ | 搜尋結果列表 |
d | 刪除選定的檔案或行 |
Esc | 退出目前窗格或對話框 |
Enter (在對話框中)/ y | 確認動作 |
Esc (在對話框中)/ n | 取消操作 |
h 、 l 、 Tab (在對話方塊中) | 導航對話框選項 |
serpl
使用設定檔來管理按鍵綁定和其他設定。預設情況下,可以透過執行serpl --version
找到設定檔的路徑。您可以使用各種檔案格式進行配置,例如 JSON、JSON5、YAML、TOML 或 INI。
{
"keybindings" : {
"<Ctrl-d>" : " Quit " ,
"<Ctrl-c>" : " Quit " ,
"<Tab>" : " LoopOverTabs " ,
"<Backtab>" : " BackLoopOverTabs " ,
"<Ctrl-o>" : " ProcessReplace " ,
"<Ctrl-b>" : " ShowHelp "
}
}
{
keybindings : {
"<Ctrl-d>" : "Quit" ,
"<Ctrl-c>" : "Quit" ,
"<Tab>" : "LoopOverTabs" ,
"<Backtab>" : "BackLoopOverTabs" ,
"<Ctrl-o>" : "ProcessReplace" ,
"<Ctrl-b>" : "ShowHelp" ,
} ,
}
keybindings :
" <Ctrl-d> " : " Quit "
" <Ctrl-c> " : " Quit "
" <Tab> " : " LoopOverTabs "
" <Backtab> " : " BackLoopOverTabs "
" <Ctrl-o> " : " ProcessReplace "
" <Ctrl-b> " : " ShowHelp "
[ keybindings ]
"<Ctrl-d>" = " Quit "
"<Ctrl-c>" = " Quit "
"<Tab>" = " LoopOverTabs "
"<Backtab>" = " BackLoopOverTabs "
"<Ctrl-o>" = " ProcessReplace "
"<Ctrl-b>" = " ShowHelp "
[keybindings]
<Ctrl-d> = Quit
<Ctrl-c> = Quit
<Tab> = LoopOverTabs
<Backtab> = BackLoopOverTabs
<Ctrl-o> = ProcessReplace
<Ctrl-b> = ShowHelp
您可以透過以您選擇的格式修改設定檔來自訂按鍵綁定。
提示
如果目前目錄很大,則必須按一下Enter
才能開始搜尋。
/
鍵搜尋列表。Ctrl + b
組合鍵顯示幫助對話框。Ctrl + o
組合鍵對所有檔案進行替換。r
鍵處理所選檔案或行的替換。Ctrl + n
組合鍵在搜尋和取代模式之間切換。g
、 G
、 j
和k
鍵瀏覽搜尋結果。d
鍵刪除選定的檔案或行。 查看 Neovim 的toggleterm.nvim 插件,它提供了一個可以透過按鍵綁定切換的終端。或者,如果您使用 AstroNvim,則可以使用以下配置:
return {
" akinsho/toggleterm.nvim " ,
cmd = { " ToggleTerm " , " TermExec " },
dependencies = {
{
" AstroNvim/astrocore " ,
opts = function ( _ , opts )
local maps = opts . mappings
local astro = require " astrocore "
maps . n [ " <Leader>t " ] = vim . tbl_get ( opts , " _map_sections " , " t " )
local serpl = {
callback = function ()
astro . toggle_term_cmd " serpl "
end ,
desc = " ToggleTerm serpl " ,
}
maps . n [ " <Leader>sr " ] = { serpl . callback , desc = serpl . desc }
maps . n [ " <Leader>tf " ] = { " <Cmd>ToggleTerm direction=float<CR> " , desc = " ToggleTerm float " }
maps . n [ " <Leader>th " ] = { " <Cmd>ToggleTerm size=10 direction=horizontal<CR> " , desc = " ToggleTerm horizontal split " }
maps . n [ " <Leader>tv " ] = { " <Cmd>ToggleTerm size=80 direction=vertical<CR> " , desc = " ToggleTerm vertical split " }
maps . n [ " <F7> " ] = { ' <Cmd>execute v:count . "ToggleTerm"<CR> ' , desc = " Toggle terminal " }
maps . t [ " <F7> " ] = { " <Cmd>ToggleTerm<CR> " , desc = " Toggle terminal " }
maps . i [ " <F7> " ] = { " <Esc><Cmd>ToggleTerm<CR> " , desc = " Toggle terminal " }
maps . n [ " <C-'> " ] = { ' <Cmd>execute v:count . "ToggleTerm"<CR> ' , desc = " Toggle terminal " }
maps . t [ " <C-'> " ] = { " <Cmd>ToggleTerm<CR> " , desc = " Toggle terminal " }
maps . i [ " <C-'> " ] = { " <Esc><Cmd>ToggleTerm<CR> " , desc = " Toggle terminal " }
end ,
},
},
opts = {
highlights = {
Normal = { link = " Normal " },
NormalNC = { link = " NormalNC " },
NormalFloat = { link = " NormalFloat " },
FloatBorder = { link = " FloatBorder " },
StatusLine = { link = " StatusLine " },
StatusLineNC = { link = " StatusLineNC " },
WinBar = { link = " WinBar " },
WinBarNC = { link = " WinBarNC " },
},
size = 10 ,
--- @param t Terminal
on_create = function ( t )
vim . opt_local . foldcolumn = " 0 "
vim . opt_local . signcolumn = " no "
if t . hidden then
local toggle = function () t : toggle () end
vim . keymap . set ({ " n " , " t " , " i " }, " <C-'> " , toggle , { desc = " Toggle terminal " , buffer = t . bufnr })
vim . keymap . set ({ " n " , " t " , " i " }, " <F7> " , toggle , { desc = " Toggle terminal " , buffer = t . bufnr })
end
end ,
shading_factor = 2 ,
direction = " float " ,
float_opts = { border = " rounded " },
},
}
該項目已獲得 MIT 許可證的許可。有關詳細信息,請參閱許可證文件。
(開發中)