itsuki0927 / SkCode

SkCode = neovim + lua + vscode
138 stars 20 forks source link

功能增强:move.nvim插件,提供类似vscode alt+方向键快速移动代码 #18

Open bigboysuper6 opened 1 year ago

bigboysuper6 commented 1 year ago

path:lua/core/plugin/list.lua

 --move-nvim 提供快速移动代码的插件
  {
    'fedepujol/move.nvim',
    lazy=false,
    init = function()
      require('core.mappings').move()
    end,
  }

path:lua/core/mappings.lua

--move.nvim mapping
M.move = function()
 local opts = { noremap = true, silent = true }
-- Normal-mode commands
vim.keymap.set('n', '<A-Down>', ':MoveLine(1)<CR>', opts)
vim.keymap.set('n', '<A-Up>', ':MoveLine(-1)<CR>', opts)
vim.keymap.set('n', '<A-Left>', ':MoveHChar(-1)<CR>', opts)
vim.keymap.set('n', '<A-Right>', ':MoveHChar(1)<CR>', opts)
vim.keymap.set('n', '<leader>wf', ':MoveWord(1)<CR>', opts)
vim.keymap.set('n', '<leader>wb', ':MoveWord(-1)<CR>', opts)
-- Visual-mode commands
vim.keymap.set('v', '<A-Down>', ':MoveBlock(1)<CR>', opts)
vim.keymap.set('v', '<A-Up>', ':MoveBlock(-1)<CR>', opts)
vim.keymap.set('v', '<A-Left>', ':MoveHBlock(-1)<CR>', opts)
vim.keymap.set('v', '<A-Right>', ':MoveHBlock(1)<CR>', opts)
end

move.nvim