Nano: line numbers with bell suppression and smooth scrolling – unresolved update lag
0 reputation · 20 Apr 2024, 22:19 UTC
0 reputation · 20 Apr 2024, 22:19 UTC
Set up nano to display line numbers in the status bar, suppress the audible bell, and enable smooth scrolling.
The set linenumbers directive is global and updates as the cursor moves, but it does not toggle per file. The set bell-style none option silences only the audible bell, leaving visual prompts untouched. When set smooth is enabled, the line number display may lag or fail to update consistently on certain terminals, and the set mouse feature can further interfere with accuracy during mouse‑driven navigation.
1. Does the combination of set linenumbers and set smooth inherently cause status bar lag on some terminal types?
2. Is there a nano configuration or patch that guarantees immediate line number updates while smooth scrolling is active?
3. How does enabling set mouse affect line number accuracy when both set linenumbers and set smooth are in use?
35275 reputation · 21 Apr 2024, 01:00 UTC
Yes, the combination of set linenumbers and set smoothscroll can cause a perceptible lag in the status bar on some terminals. The lag is not a bug in Nano itself but a side effect of the terminal’s redrawing strategy when smooth scrolling forces a full screen refresh on each key event. The set bellstyle none directive only silences the audible bell and does not affect scrolling behaviour.
smoothscroll enabled, Nano sends a full screen redraw for every line‑wise movement. When line numbers are also displayed, the margin must be recalculated and redrawn each time.scrollok or scrolldown support may fall back to a slower repaint routine, amplifying the lag.mouse option can trigger additional cursor reposition events, adding to the redraw load.set linenumbers
set bellstyle none
set smoothscroll
# Optional: disable mouse if you notice extra lag
# unset mouse
touch test.txt; for i in {1..500}; do echo $i >> test.txt; done). Verify that:
Ctrl+G produces no audible or visual bell.set smoothscroll and compare the scroll speed.echo $TERM.
infocmp $TERM | grep -E 'cursor|scroll' to see if the terminal advertises efficient scrolling capabilities.
xterm to gnome-terminal or alacritty) to see if the issue is emulator‑specific.
Providing the output of echo $TERM and the relevant infocmp snippet will let us pinpoint whether the lag is due to terminal limitations or Nano’s rendering logic.
Use comments to ask for clarification. Post a solution as an answer.
7,000 reputation · 21 Apr 2024, 00:36 UTC
Nano’s set linenumbers draws numbers in the left margin, while set constantshow (or the Meta+Shift+# toggle) shows the current line/column in the status bar. The lag you observe with set smoothscroll affects the margin numbers because Nano must redraw the margin on each line‑wise move; the status‑bar constantshow updates instantly as it only reads the cursor position.
Therefore, if you need immediate feedback without margin redraw, enable constantshow instead of (or in addition to) linenumbers. Bell suppression (set bellstyle none) works independently of both displays.
Verification: start Nano with nano -c (constantshow) and scroll; the status bar updates without delay even when set smoothscroll is active. Compare with nano -l to see the margin lag.