6 ms·
Can I use a non-monospaced font in either Vim or gVim?
- sunstone 8y agoI hope not.
- namnemul 8y agoWhy not? There are enough people that use Vim to just write prose. You don’t need monospaced fonts then.
- mseepgood 8y agoI also program in non-monospaced fonts. There is no reason not to.
- stinos 8y agoNo reason at all? Not saying you're wrong per se, but basically you're saying all the monospaced fonts out there used by default in a ton of code editors are there for no reason. Or at least not a good one. Can you elaborate?
- Stratoscope 8y agoMany programmers believe that it is impossible, or at least impractical, to code effectively in a monospaced font. For most kinds of code, this is a mistaken belief. You only need a monospaced font if you want to use column alignment. But it's really quite rare that column alignment is necessary. It can almost always be replaced with simple indentation. Here's what I mean by column alignment: function foo(firstArgument, secondArgumentFunctionCall(itsArgument, itsOtherArgument), thirdArgument) { bar(); } Obviously, those arguments won't line up in a proportional font. But this kind of column alignment is a bad practice anyway. It leads to excessive line lengths, spurious VCS diffs, and is just generally fiddly. The Rust/Servo coding guidelines formerly mandated column alignment like this. But after seeing the problems it caused in their codebase, they switched to a pure indentation style like the one I've used for many years. The idea is simple. Stop making a distinction between statements and expressions, and instead format expressions just as you would format blocks of statements: function foo( firstArgument, secondArgumentFunctionCall( itsArgument, itsOtherArgument ), thirdArgument ) { bar(); } Once you start using this kind of format, it no longer matters whether you use a monospaced or proportional font. It doesn't even matter whether you use tabs or spaces! The notion of "tabs for indentation, spaces for alignment" goes away when you don't use alignment. I think every programmer should try using proportional fonts for a while. Even if you decide you prefer monospaced after all, it's an educational experience to see that monospaced fonts are just not necessary for most programming, and that tabs work fine once you stop using alignment.
- geezerjay 8y ago> Many programmers believe that it is impossible, or at least impractical, to code effectively in a monospaced font. Your post was the very first place I've ever saw that assertion in any shape or form. I never heard anyone come close to make that assertion ever. Moreover, modern IDEs started featuring functionalities that rely on monospace fonts, such as selecting blocks of text by both rows and columns. You should pass off your personal opinion as your own personal opinion instead of posting baseless assertions wrapped in an unbelievable appeal to popularity.
- pmoriarty 8y ago> > Many programmers believe that it is impossible, or at least > > impractical, to code effectively in a monospaced font. > > Your post was the very first place I've ever saw that assertion in > any shape or form. I never heard anyone come close to make that > assertion ever. That's almost certainly a typo, and the GP almost certainly meant to say "without a monospace font" or "in a proportional font". In fact, 2 sentences later he/she says "You only need a monospaced font if you want to use column alignment." This is presumably meant to contradict the assertion in the first sentence.
- Stratoscope 8y agoI'm sorry, I meant to get back to you a week ago. As pmoriarty pointed out, that was indeed a typo, and a rather embarrassing one! The funny thing was that as I was writing that sentence, I first wrote: "The vast majority of programmers believe..." And then I decided to tone down the language a bit. But my initial wording would have made the typo fairly obvious. So it goes. :-) > functionalities that rely on monospace fonts, such as selecting blocks of text by both rows and columns. I use that "column selection" mode with proportional fonts too. It works fine, even though the selected block has ragged right edges.
- wruza 8y agoVCS diffs are broken by design (in a sense of this subthread). Remove a single “if” around a block of code, reindent it, and now you got all lines changed. I wish VCS had special modes for source code that would compare lextoken-wise and show only what actually changed, leaving formatting to personal tastes. Yeah, no more style wars: tab/space, space/newline/none, trailing comma – all become irrelevant. Sigh. Edit: a worst nightmare is a diff that removed “if” and also fixed a mistype in one of 20 reindented lines.
- geezerjay 8y ago> but basically you're saying all the monospaced fonts out there used by default in a ton of code editors are there for no reason. That assertion only makes sense if you assume that indentation or even indentation style have no relevance in software development, and thus there is no reason to consider those basic requirements in any activity related to coding.
- deleted 8y ago[deleted]
- metaphor 8y agoWas curious what language(s) you regularly program in, and if you generally develop/maintain solo or as part of a team? I don't agree with your disposition, but I don't think it's necessarily wrong either...perhaps subjectively driven based on your "norm" vs. what others have experienced, e.g. I ocassionally program in a niche language where the first 7 columns are strictly defined by BNF, uses relatively heavy ASCII art commenting by local coding convention, and will throw obscure errors if a character on any line exceeds the 80th.
- ur-whale 8y ago>There is no reason not to If you've reached that conclusion, I suspect I would not enjoy reading your code very much.
- geezerjay 8y ago>There are enough people that use Vim to just write prose. One of vim's main features is enabling users to navigate by row/vertically while traversing the same column. If someone uses non-monospace fonts then columns won't be aligned and that sort of move makes traversing text an illogical and unintelligible endeavour. Thus defeating the whole point of using vim.
- ealhad 8y agoI thought the whole point of using vim was having access to powerful, mnemonics and highly composable commands to edit text efficiently… Guess I was wrong.
- geezerjay 8y agoComposable, yes, as in compose movements with commands. The thing is, that only works if the user is able to understand what a movement does and know exactly where the cursor ends up after a command. With non-monospace fonts that is not possible, as users have no clear idea where the cursor will end up after, say, pressing j or k. That's the point.
- ealhad 8y agoDo you often use j or k? I know I don't. Text objects (word, paragraph, brackets, quotes, sentence, etc) usually do everything I need.
- geezerjay 8y ago> Do you often use j or k? Yes, extensively. I mean jk let users navigate between adjacent statements. That's a pretty basic usecase. In fact, they are used more often than i or l as word movements express intent more clearly than moving a character at a time.
- ur-whale 8y ago>Do you often use j or k All the time. All the more so because I code using vertical alignments.
- quickthrower2 8y agoWhy not offer people some rope?
- cup-of-tea 8y agoOne way is to use emacs and use evil-mode for vi behaviour. I use proportional fonts for a few things in emacs. It's really nice.
- chungy 8y agoIt sounds counter-intuitive to use another editor, especially Emacs, but this might actually be the best advice. Emacs is on top of the game for proportional text editing, as well as the ability to make it behave very much (even exactly so) like Vim. I'd recommend watching this talk for why: https://www.youtube.com/watch?v=JWD1Fpdd4Pc https://www.youtube.com/watch?v=JWD1Fpdd4Pc
- anotheryou 8y agocan look so good :) https://lepisma.github.io/2017/10/28/ricing-org-mode/index.html https://lepisma.github.io/2017/10/28/ricing-org-mode/index.h...
- b0rsuk 8y agoMonospaced fonts also mean monospaced puctuation. Punctuation is super important in programming languages. In human-human languages, a comma, a dot or a semicolon is mostly just icing on the cake. There are examples where it can completely change the meaning of a sentence, but for most part puctuation errors are easy to spot, meaning can be inferred and it's largely a matter of taste. In human-computer languages, a misplaced punctuation character really shakes things up. Summary: monospaced fonts give punctuation weight equal to words, which is how it works in programming. I want non-alphanumeric characters like ,.;:`'"[]()}{!@#$^%%^*&() stand out. Notice how the left part of characters I just listed are hard to distinguish at a glance? And what if I need to count adjacent underscores, spaces or semicolons? Variable length characters are optimised for prose and human-human communication.
- genericid 8y agoNonsense. Monospaced fonts do not give punctuation weight equal to words. Fonts that give punctuation weight equal to words do. See for example the Input font family: http://input.fontbureau.com/ http://input.fontbureau.com/
- ur-whale 8y agoI've never understood the attraction of non-monospaced font in an editor. Especially when you code, where you basically read as much in the vertical direction than in the horizontal. Monospaced fonts allows for super-fast vertical pattern matching on the code which helps your brain tremendously. To me, non-monospaced font in an editor is exactly as if each letter in a line of text was placed at a somewhat random height, a very unpleasant experience.
- ealhad 8y agoI don't understand. Doesn't vertical pattern matching works the same for monospaced and proportional fonts? The same words are still the same size.
- ur-whale 8y ago>The same words are still the same size Try to properly vertically align code for a matrix containing expressions with X's and Y's in a non-monospaced font.
- ealhad 8y agoI see. That's kinda specific though, and not all code has matrices in it. But I get your point.
- ur-whale 8y ago> not all code has matrices in it It's not just matrices. An array of colors in hexadecimal is a good example of something that will make your eyeballs bleed with a non-monospaced font. I also tend to do matrix-style aligment with complex expressions that have repetitive patterns.
- ealhad 8y agoI see. I tried using a proportional font for ~15 minutes and didn't encounter these problems, I guess I'll try a bit longer and keep your point in mind.
- ealhad 8y agoFor the Emacs users wanting to try this… M-x variable-pitch-mode Vim users, I can assure you that Evil is a really good implementation of Vim, which happens to run in a really good environment.
- pmoriarty 8y agoUnfortunately, this requires the use of gui-emacs, while my entire emacs config is geared towards use from a terminal.
- ealhad 8y agoIndeed.
- cup-of-tea 8y agoYes, emacs GUI is more fit for purpose. If you use a terminal emulator you have to choose one or the other (assuming you even can) while emacs allows you to mix and match at will, even within the same file. I fully expect nobody will try emacs due to religious reasons, though.
- jypepin 8y agoI'm surprised that most comments here are just avoiding the problem saying that nobody would want a non-monospace font in an editor, without trying to understand the original reason for this and even think about the fact that someone might be using vim a different way.
- ohhellno 8y agoI switched from vim full-time to using vscode with the vim plugin for most things. The plugin has gotten better over time and at this point all of my familiar bindings just work as they do in vim. Changing the font is easy.