Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<c-u> support #276

Open
mawkler opened this issue Aug 31, 2022 · 6 comments
Open

<c-u> support #276

mawkler opened this issue Aug 31, 2022 · 6 comments
Labels
enhancement New feature or request pinned

Comments

@mawkler
Copy link

mawkler commented Aug 31, 2022

Is your feature request related to a problem? Please describe.

Pressing <c-u> in insert mode once deletes everything to the left of the cursor up to the point where you entered insert mode. However, it leaves any parenthesis created to the right of the cursor.

To illustrate, here's an example where we've just entered inser mode (| is the cursor):

foo |

Pressing (bar produces this:

foo (bar|)

Pressing <c-u> now produces this:

foo |)

But I would expect it to produce this (i.e. remove everything I inserted from insert mode):

foo |
@mawkler mawkler added the enhancement New feature or request label Aug 31, 2022
@stale
Copy link

stale bot commented Oct 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Oct 31, 2022
@mawkler
Copy link
Author

mawkler commented Oct 31, 2022

Hello, Mr. Bot. Please don't close this issue because it hasn't been resolved yet.

@stale stale bot removed the wontfix This will not be worked on label Oct 31, 2022
@Mr-LLLLL
Copy link

Mr-LLLLL commented Dec 27, 2022

i meet some problem like this, i think it's same type.

(
|
)

after i key backspace, it like

(|
)

i think follow is pretty goods

(|)

and key backspace again

|
)

i think backspace '(', matched ')' may be deleted. just like

|

@stale
Copy link

stale bot commented Feb 25, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Feb 25, 2023
@mawkler
Copy link
Author

mawkler commented Feb 27, 2023

Hi again Mr. Bot. I still have hope for this issue, don't close it yet please.

@stale stale bot removed the wontfix This will not be worked on label Feb 27, 2023
@windwp windwp added the pinned label Mar 3, 2023
@Sam-programs
Copy link
Contributor

Sam-programs commented Sep 19, 2023

local api = vim.api
local insertCursorCol = 0
vim.api.nvim_create_autocmd({ "InsertEnter" }, {
   pattern = "*",
   callback = function()
      _, insertCursorCol = unpack(api.nvim_win_get_cursor(0));
   end,
})

vim.keymap.set("i", "<C-u>", function()
   local _, cursorCol = unpack(api.nvim_win_get_cursor(0));
   local colDistance = cursorCol - insertCursorCol
   local backspaces = ''
   for i = 1, colDistance, 1 do
     backspaces = backspaces .. '<BS>' 
   end
   return backspaces
end, { remap = true, expr = true })

this calls nvim-autopair's backspace using recursive mapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned
Projects
None yet
Development

No branches or pull requests

4 participants