Neovim插入模式,注入预定义文本(Elixir Pipe Operator)

发布于 2025-02-11 20:32:39 字数 421 浏览 1 评论 0原文

我想在插入模式下复制Rstudio的“插入管道操作员”热键。 当点击< cm>时,我希望要输入以下符号:|>

这可能吗?

我尝试了以下内容:

# Keybind function
local function map(mode, lhs, rhs, opts)
  local options = {noremap = true}
  if opts then options = vim.tbl_extend('force', options, opts) end
  vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end

# Not working
map('i', '<C-M>', '|>')

I would like to replicate RStudio's "insert pipe operator" hotkey in insert mode.
When hitting <C-M>, I would like the following symbols to be typed: |>.

Is this possible?

I have tried the following:

# Keybind function
local function map(mode, lhs, rhs, opts)
  local options = {noremap = true}
  if opts then options = vim.tbl_extend('force', options, opts) end
  vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end

# Not working
map('i', '<C-M>', '|>')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光暖心i 2025-02-18 20:32:39

我的示例的问题是Neovim已经在使用&lt; cm&gt;

以下工作:

local function map(mode, lhs, rhs, opts)
  local options = {noremap = true}
  if opts then options = vim.tbl_extend('force', options, opts) end
  vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end

map('i', '<C-e>', '|>')

The issue with my example was that <C-m> is already in use by neovim.

The following works:

local function map(mode, lhs, rhs, opts)
  local options = {noremap = true}
  if opts then options = vim.tbl_extend('force', options, opts) end
  vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end

map('i', '<C-e>', '|>')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文