-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[feature request] relative line numbers in vim mode #4116
Comments
FYI, with today's CodeMirror APIs this is actually not that hard. Basic hacky implementation that works on codemirror.net: function showRelativeLines(cm) {
const lineNum = cm.getCursor().line + 1;
if (cm.state.curLineNum === lineNum) {
return;
}
cm.state.curLineNum = lineNum;
cm.setOption('lineNumberFormatter', l =>
l === lineNum ? lineNum : Math.abs(lineNum - l));
}
editor.on('cursorActivity', showRelativeLines) |
How would you implement this in cm6? |
The vim code is now being maintained at https://github.com/replit/codemirror-vim/ . If this is still important, check whether there is an issue open for it there. |
@marijnh Can you update this page https://codemirror.net/5/demo/vim.html regarding active maintenance? I know it's for v5 but it's always the first page I hit whenever I google "codemirror vim" (and not everyone knows that v6 has a different story) and everyone repeats that there's no active maintainer. |
Good idea. Done in fbe87a2 |
Something I miss from using terminal vim is the option to have relative line numbers; here is an illustration: http://jeffkreeftmeijer.com/images/relativenumber.gif
It would be enabled with
:set relativenumber
and was very useful for quickly jumping up and down to the desired line (e.g.10j
goes down ten lines) Without them, jumping a desired line often involves either guessing the offset, or repeatedly tappingj
/k
(an antipattern). One could also jump to the absolute line number, e.g.1234gg
, however for large files this is pretty slow.Relative line numbers as an option would definitely be great to have in vim mode.
The text was updated successfully, but these errors were encountered: