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

Repeat last movement #132

Open
rawaludin opened this issue Jun 10, 2017 · 2 comments
Open

Repeat last movement #132

rawaludin opened this issue Jun 10, 2017 · 2 comments

Comments

@rawaludin
Copy link

rawaludin commented Jun 10, 2017

Is it possible to bind last movement to some keyboard shortcut?
I hate pressing ]q or other binding multiple times to go to next item.
Let say after I first press ]q or other binding, then I could press key like ]] to trigger the last binding I use.

If not possible, just close this issue.

Thanks. :)

@saaguero
Copy link

saaguero commented Jul 2, 2017

In the meantime, I suggest you create your own mappings to improve those tiny things you can't deal with.

Like you, I tend to use ]q [q a lot, hence I added the following mappings, which gives me a nicer experience overall.

nnoremap <silent> <A-up> :cprevious<cr>
nnoremap <silent> <A-down> :cnext<cr>

@vividn
Copy link

vividn commented May 15, 2024

Not exactly what you're looking for, but I created a keymap for [' to store a letter in the 'b' register (for bracket), and then mapped [[ to execute [ + the contents of the b register:

-- for repeating bracket commands (like from unimpaired), make a command to a letter in the b register which can then be repeated easily with [[ or ]]
function store_b_register()
  local key = vim.fn.getcharstr()
  vim.fn.setreg('b', key)
end

vim.keymap.set('n', "['", ':lua store_b_register()<CR>', { remap = false, silent = true })
vim.keymap.set('n', "]'", ':lua store_b_register()<CR>', { remap = false, silent = true })
vim.keymap.set('n', '[[', function() return '[' .. vim.fn.getreg('b') end, { expr = true, remap = true, silent = true, desc = "[@b"})
vim.keymap.set('n', ']]', function() return ']' .. vim.fn.getreg('b') end, { expr = true, remap = true, silent = true, desc = "]@b" })

Note that this is in lua, not vimscript, but I think it could be translated easily enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants