zed icon indicating copy to clipboard operation
zed copied to clipboard

Vim: absolute numbering in any mode except `insert` mode

Open Conaclos opened this issue 1 year ago • 2 comments

Check for existing issues

  • [X] Completed

Describe the feature

I am using the following vim configuration that allows relative numbering in any mode except in insert mode:

set relativenumber # Relative line numbering

autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber

For now, Zed forces me to choose between relative line numbering or absolute line numbering.

I am not sure how this feature should be introduced. I see two possible approaches:

  • add a new option line_numbers that takes absolute, relative and both as values. both could be the behavior I described here. Unfortunately I didn't find a better name...
  • add a way to change settings using contexts (the same concept used by keymaps). We could imagine something like:
    {
      "context": "vim_mode == insert",
      "settings": { "relative_line_numbers": false }
    },
    {
      "context": "vim_mode != insert",
      "settings": { "relative_line_numbers": true }
    }
    
    However, this could introduce many issues. For example: should we accept any settings like theme, ...?

If applicable, add mockups / screenshots to help present your vision of the feature

No response

Conaclos avatar Aug 20 '24 10:08 Conaclos

Can refer to the VSCode Vim plugin to add a setting for smart relative line numbers. https://github.com/VSCodeVim/Vim/issues/3020

0x2CA avatar Aug 21 '24 02:08 0x2CA

I know I'm in the minority but I usually use both numbering in Neovim, absolute and relative side-by-side so an option for showing both would be awesome.

This is how Neovim does it:

absolute-relative

feketegy avatar Aug 23 '24 09:08 feketegy

I know I'm in the minority but I usually use both numbering in Neovim, absolute and relative side-by-side so an option for showing both would be awesome.

This is how Neovim does it:

absolute-relative absolute-relative

Would love this, too. Don't know why this is already marked "closed".

LittleFat3Tuan avatar Sep 05 '24 06:09 LittleFat3Tuan

@LittleFat3Tuan Sounds like a different feature request than the one described here. Could you please open a separate issue for it.

ConradIrwin avatar Sep 05 '24 14:09 ConradIrwin

Has anything been done in this regard? Relative line numbers are a must locally, but when you're scrolled 200 lines away from your cursor (e.g. because you're trying to scroll to the line number from a stack trace), they are useless and actually counterproductive. Context-sensitive absolute line numbers would be awesome. Always side-by-side would be a trade-off although bloaty (but a setting can't harm I guess)

muja avatar Apr 28 '25 10:04 muja