Comments (11)
This breaks the expected behavior of most if not all modern text editors...I hope this could be an easy fix...Many Thnxs!
What "all modern text editors" have a Normal mode?
from neovim.
from neovim.
Isn't this behavior expected, matching the behavior of "+p
? or are you claiming the behavior differs from "+p
in which case I wasn't able to reproduce on iTerm
from neovim.
This is the expected behavior.
from neovim.
Hi, thanks! It should be +P
when in normal mode as far as i understand...or at least should be configurable somehow...no?
from neovim.
If it's equivalent to P
instead then it's not possible to paste after end of line, which is much more common.
from neovim.
@zeertzjq thnxs! It is very very common to do this at the beginning (and middle) of a line as well...
is there any possibility to have logic to check what position the cursor + mode the editor is in?
In Insert mode everything works fine. Maybe check the mode and if in normal mode, change to insert mode before pasting or appending? or perhaps there's a better way you can think of since you know best...Many thnxs!
from neovim.
Hi! Incidentally, in visual select mode it also works as expected. Only normal mode is off by one character when not at the end of line...
This breaks the expected behavior of most if not all modern text editors...I hope this could be an easy fix...Many Thnxs!
from neovim.
There is a way to achieve this by overriding vim.paste()
. To paste before cursor when at the beginning of a line:
vim.paste = (function(overridden)
return function(lines, phase)
if
phase < 2
and vim.api.nvim_get_mode().mode == 'n'
and vim.api.nvim_win_get_cursor(0)[2] == 0
then
overridden({}, 1)
debug.setupvalue(overridden, 5, true)
phase = phase == -1 and 3 or 2
end
overridden(lines, phase)
end
end)(vim.paste)
If you want to do that in the middle of a line as well then adjust the vim.api.nvim_win_get_cursor(0)[2] == 0
condition.
Although note that this solution uses debug.setupvalue()
, so it may stop working if Nvim's vim.paste()
implementation changes.
from neovim.
You got me on that! : )
from neovim.
Hi! This seems to work with virtualedit = "onemore"
enabled.
vim.paste = (function(overridden)
vim.opt.virtualedit = "onemore"
return function(lines, phase)
local eol = vim.fn.col "$"
if
phase < 2
and vim.api.nvim_get_mode().mode == "n"
and vim.api.nvim_win_get_cursor(0)[2] < eol
then
overridden({}, 1)
debug.setupvalue(overridden, 5, true)
phase = phase == -1 and 3 or 2
end
overridden(lines, phase)
end
end)(vim.paste)
I hope other people find this useful. If there is a more practical solution that can't broken or is future-proof please let me know...
Thank you so much for your responses and the great work you all have put in to making this fantastic piece of software.
from neovim.
Related Issues (20)
- netrw "-" go up dir not working HOT 2
- LSP: Support for typescript / typescript-language-server's "Go to Source Definition" command HOT 5
- LSP: user can easily discover, define client commands HOT 11
- Crash "nvim: /home/runner/work/neovim/neovim/src/nvim/message.c:2392: msg_scroll_flush: Assertion `to_scroll >= 0' failed." HOT 9
- popup windows should have URI for lsp extensions HOT 2
- cursorcolumn drastically slows down scrolling HOT 3
- Bicep omnifunc completion mismatch between popup menu and inserted selection HOT 3
- node.js :checkhealth code has runtime error HOT 2
- `vim.base64.decode()` return value is truncated HOT 1
- configdir does not take into account HOME env HOT 1
- Loss of Arbitrary Functions in Autocommands After Upgrading to Neovim nightly (v0.10.0-dev-2830) HOT 1
- Python Tree-sitter @spell highlights string prefixes HOT 5
- custom lint rules for Lua code HOT 2
- Lightweight enhancements to documentation syntax HOT 14
- The help docs do not work correctly with vimdoc TS parser installed HOT 5
- Fixing `'shell'` on Windows, properly HOT 12
- LSP: hook into all inbound and outbound requests HOT 3
- Default colorscheme incorrect HOT 10
- ts_parser__handle_error HOT 2
- Neovim crash almost instantly on MacOS (SEGFAULT) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neovim.