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 许可证的许可。有关详细信息,请参阅许可证文件。
(开发中)