简体   繁体   English

如何向 emacs -nw linum-mode 添加填充?

[英]How to add padding to emacs -nw linum-mode?

I am using Emacs -nw in Ubuntu.我在 Ubuntu 中使用 Emacs -nw。 I like to turn on linum-mode to see line numbers on the left margin, but the numbers are put right next to my code.我喜欢打开 linum-mode 来查看左边距的行号,但是这些数字放在我的代码旁边。

I would love it if there could be some 'padding', like 1-character long, between line number and code.如果在行号和代码之间可以有一些“填充”,比如 1 个字符长,我会喜欢它。 sorry I can't post an image since they are asking for 10 reputation, which I dont have:(抱歉,我无法发布图片,因为他们要求 10 名声望,而我没有:(

How can I do this?我怎样才能做到这一点?

["

You can use the variable linum-format<\/code> to achieve this.<\/i>您可以使用变量linum-format<\/code>来实现这一点。<\/b> Its value can either be a format string or a function which is called with line number as an argument.<\/i>它的值可以是格式字符串或以行号作为参数调用的函数。<\/b> emacswiki<\/a> has a couple of example of setting it to a format string<\/i> emacswiki<\/a>有几个将其设置为格式字符串的示例<\/b><\/p>

1) The following adds a space after the line-number<\/i> 1)以下在行号后添加一个空格<\/b><\/p>

(setq linum-format "%d ")

In addition to the other answer(s) in this thread, options for putting distance between the line numbers and the text include, but are not limited to, adjusting the fringe width (and also set the color if you so choose).除了此线程中的其他答案之外,用于放置行号和文本之间距离的选项包括但不限于调整边缘宽度(如果您选择,还可以设置颜色)。

The fringe is like a vertical ruler that runs from the top to the bottom of the buffer -- the left fringe is sandwiched between the line numbers and the text.边缘就像一个垂直的尺子,从缓冲区的顶部延伸到底部——左边缘夹在行号和文本之间。 It can be invisible if it is the same color as the default background of the user, or it can be a different color.如果它与用户的默认背景颜色相同,则它可以是不可见的,也可以是不同的颜色。

(setq-default left-fringe-width  10)

(setq-default right-fringe-width  0)

(set-face-attribute 'fringe nil :background "black")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM