fedepujol / move.nvim Goto Github PK
View Code? Open in Web Editor NEWGain the power to move lines and blocks and auto-indent them!
License: GNU General Public License v3.0
Gain the power to move lines and blocks and auto-indent them!
License: GNU General Public License v3.0
Thanks for the great plugin! I would like to ask for something extra. It would be great if move.nvim
can detect some popular wrapper and anchor characters and use it to swap horizontally everything between.
Please see examples below, |
is the cursor:
require("move.nvim").setup({
custom_anchors: { "{,}", "<,>" },
})
In TypeScript, sometimes I want to swap the imports:
// before
import { |Something, type Other, Else } from 'somewhere';
// move.nvim can detect my cursor is inside the wrapper `{ ... }` with `,` anchor,
// so if I use MoveWord(1), it will become:
import { type Other, |Something, Else } from 'somewhere';
This is also useful in some cases like:
// before
forwardRef<SomeProps, typeof Other>(...)
// move.nvim can detect my cursor is inside `< ... >` wrapper with `,` anchor
// so if I use MoveWord(), it will become:
forwardRef<typeof Other, SomeProps>(...)
This plugin kind of works sometimes, and sometimes it does not in an unpredictable way and I can't really find a pattern in here.
I have followed the installation instructions (without Legendary) and I'm using LazyNvim.
return {
"fedepujol/move.nvim",
config = function()
local opts = { noremap = true, silent = true }
-- Normal-mode commands
vim.keymap.set('n', '<A-j>', ':MoveLine(1)<CR>', opts)
vim.keymap.set('n', '<A-k>', ':MoveLine(-1)<CR>', opts)
vim.keymap.set('n', '<A-h>', ':MoveHChar(-1)<CR>', opts)
vim.keymap.set('n', '<A-l>', ':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-j>', ':MoveBlock(1)<CR>', opts)
vim.keymap.set('v', '<A-k>', ':MoveBlock(-1)<CR>', opts)
vim.keymap.set('v', '<A-h>', ':MoveHBlock(-1)<CR>', opts)
vim.keymap.set('v', '<A-l>', ':MoveHBlock(1)<CR>', opts)
end,
}
Is there something I'm missing?
This mappings:
vnoremap <silent> <A-j> <cmd>lua require('move').MoveBlock(1)<CR>
vnoremap <silent> <A-k> <cmd>lua require('move').MoveBlock(-1)<CR>
vnoremap <silent> <A-l> <cmd>lua require('move').MoveHBlock(1)<CR>
vnoremap <silent> <A-h> <cmd>lua require('move').MoveHBlock(-1)<CR>
and their lua equivalent:
vim.keymap.set('v', '<A-j>', "<Cmd>lua require('move').MoveBlock(1)<CR>", { noremap = true, silent = true })
vim.keymap.set('v', '<A-k>', "<Cmd>lua require('move').MoveBlock(-1)<CR>", { noremap = true, silent = true })
vim.keymap.set('v', '<A-l>', "<Cmd>lua require('move').MoveHBlock(1)<CR>", { noremap = true, silent = true })
vim.keymap.set('v', '<A-h>', "<Cmd>lua require('move').MoveHBlock(-1)<CR>", { noremap = true, silent = true })
Single line/char operations works fine.
When going beyond original line length (it creates spaces), but going backwards the spaces aren't removed.
Would love to have a Lua alternative to vim-move
but currently this plugin does not work at all with my config, because I have my own lua file in my config called utils.lua
, so it creates a namespace collision with your plugin.
Your directory structure should look like this:
lua/
- move/
- init.lua <-- move.lua contents should be moved here
- utils.lua
- core/
- horiz.lua
- vert.lua
I've recorded it here, It only happens when moving the block downwards.
This was tested with more than one fold setting so I wouldn't say the issue lies there
I should point that I've faced the same issue with my hacky block-moving keybind, in fact my hope was using a more maintained solution like this plugin would fix it.
here's the same text block for testing purposes
--- defines div and mul
-- @module side
--- multiplies two numbers.
function mul(p1, p2)
return p1 * p2
end
--- divides two numbers.
function div(p1, p2)
return p1 / p2
end
-- entities: This <foo>, quot: ", ampersand: &
-- escaped markdown: __foo\_bar__
-- **bold** *italic*
local foo = 123
-- escaped markdown: `foo\_bar`
local bar = 123
local a = {}
local ASD = 123
local ASD = 123
I think it's more useful to move words around (like M-t
in emacs for transposing words) than simply moving characters. dawwP
and dawbP
can do the same except for last word in the line. So it'll be good if this plugin can handle that.
If it's not too much to ask, I'd like to suggest more variants such as for WORDS, function arguments, sentences, paragraphs, etc. (i.e. to directly swap/move without having to enter visual mode and navigate character by character or line by line).
Thanks.
๐๐ป
I've only just noticed that this plugin has stopped working for me and it now just displays a message that suggests the plugin isn't installed correctly?
E492: Not an editor command: MoveLine(1)
Here is my config...
{
"fedepujol/move.nvim",
config = function()
local opts = { noremap = true, silent = true }
-- Normal-mode commands
vim.keymap.set('n', '<C-j>', ':MoveLine(1)<CR>', opts)
vim.keymap.set('n', '<C-k>', ':MoveLine(-1)<CR>', opts)
vim.keymap.set('n', '<C-h>', ':MoveHChar(-1)<CR>', opts)
vim.keymap.set('n', '<C-l>', ':MoveHChar(1)<CR>', opts)
-- Visual-mode commands
vim.keymap.set('v', '<S-j>', ':MoveBlock(1)<CR>', opts)
vim.keymap.set('v', '<S-k>', ':MoveBlock(-1)<CR>', opts)
vim.keymap.set('v', '<S-h>', ':MoveHBlock(-1)<CR>', opts)
vim.keymap.set('v', '<S-l>', ':MoveHBlock(1)<CR>', opts)
end
}
You can see my lazy.nvim lock file here:
https://github.com/Integralist/nvim/blob/main/lazy-lock.json#L39
It's showing as being on the latest commit for this plugin.
I'm not sure why I would be seeing this specific type of error.
Any ideas?
Thanks!
I request to make a general API that detects current user mode (normal, visual or insert) automatically by using built-in nvim_get_mode()
API so we don't have to bind separate keys for moving a line or chunk of text (in visual/block mode).
Thanks!
I am trying to move the box Unicode character โ
but move.nvim splits it into ๎ ้ ๏ฟฝ
characters...
This issue is for tracking breaking changes in the plugin.
Thanks for this nice plugin.
E.g. vim-move
has this option: let g:move_auto_indent = 0
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.