folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.22k stars 27 forks source link

feature: there's no easy way to jump to the last character of the line? #320

Open name-snrl opened 3 months ago

name-snrl commented 3 months ago

Did you check the docs?

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

I can't jump to the last character of the line. May I missed something in doc, but I read it twice.

Describe the solution you'd like

I used leap.nvim and just type at EOL.

Describe alternatives you've considered

To go back to leap.nvim, idk. :D But flash is awesome!

Additional context

{
    'folke/flash.nvim',
    ---@type Flash.Config
    opts = {
      label = { uppercase = false },
      prompt = { enabled = false },
      modes = {
        search = { enabled = false },
        treesitter = { label = { rainbow = { enabled = true, shade = 2 } } },
        treesitter_search = { label = { rainbow = { enabled = true, shade = 2 } } },
      },
    },
    -- stylua: ignore
    keys = {
      'f', 'F', 't', 'T',
      { 'gs', function() require('flash').jump() end, mode = { 'n', 'x', 'o' } },
      { 'gz', function() require('flash').treesitter() end, mode = { 'n', 'x', 'o' } },
      { 'gZ', function() require('flash').treesitter_search() end, mode = { 'o', 'x' } },
      { 'r', function() require('flash').remote() end, mode = 'o' },
      {
        'ygw',
        function()
          require('flash').jump {
            action = function(match, state)
              vim.api.nvim_set_current_win(match.win)
              vim.api.nvim_win_set_cursor(match.win, match.pos)
              vim.cmd.norm { args = { 'yiw' }, bang = true }
              state:restore()
            end,
          }
        end,
      },
    },
  }
gennaro-tedesco commented 3 months ago

Is this different than the general vim motion g_?

name-snrl commented 3 months ago

Is this different than the general vim motion g_?

Of course, because the jump works across all windows and rows

gennaro-tedesco commented 3 months ago

I can't jump to the last character of the line.

but then you do not want to jump to the last character of the line, you want to mark/jump the last character-s of each line, is it correct?

name-snrl commented 3 months ago

but then you do not want to jump to the last character of the line, you want to mark/jump the last character-s of each line, is it correct?

What? I just want to jump to any character on the screen, including the last characters of the lines.

name-snrl commented 3 months ago

BTW, for the moment I found a workaround - use search mode. But there seems to be a bug with backslashes. You just can't use backslashes in search mode unless there is no backslash on the screen, in which case the search will instantly abort.

p.s. I haven't looked for issues that describe that, perhaps it already exists

brunobmello25 commented 3 months ago

Additionally, it would be nice if we could also jump to blank lines.

With leap, you can just do this by pressing s<space><space> (assuming your "leap bind" is s). Then it would show labels for every blank line (even if it doesn't actually have two spaces) and you can jump directly to them

with flash this is not currently possible, I believe

iamhrigved commented 1 month ago

@name-snrl

function()
    require("flash").jump({
    search = { mode = "search", max_length = 0 },
    label = { after = { 0, 0 } },
    pattern = "^", -- replace with $ for end of line
    })
end

This function is provided in the "Examples" section which can be used to go to the beginning of a line, but not at the end.

I think we should find a regex to put in the pattern section which matches ^ AND $ that is, the beginning AND end of line.