7 ms·
Show HN: CuteVim – Portable Vim with a cute vimrc
- 38 3y agoIt's not clear what this is. Is it Vim as a single executable? Is so, what is this doing? ./vim.com -u /zip/usr/share/vim/vimrc
- hoosieree 3y agoLooks like Vim compiled with Actually Portable Executable [1] headers to make a cross-platform (and perhaps also bare metal) vim binary. But I apparently am distracted by shiny things and couldn't focus on any of the other stuff after seeing rainbow indentation for the first time. [1]: https://justine.lol/ape.html https://justine.lol/ape.html
- tomcam 3y ago> Rock musicians have a love-hate relationship with dynamic range compression, since it removes a dimension of complexity from their music, but is necessary in order to sound professional. Bloat might work by the same principles, Speaking of which I am a bloated rock musician. I don't feel seen.
- brirec 3y agoThe actual binary (vim.com in this case) is also a valid zip file, which it can read and write as a private virtual mount point. /zip refers to files inside the binary, inside the zip file. Redbean web server (by the author of Cosmopolitan, Justine.lol) also uses this method to store its web root.
- yjftsjthsd-h 3y ago> Is it Vim as a single executable? Basically; it's using the "Actually Portable Executable" system to make a single binary that includes everything it needs including enough portability stuff to run on different systems directly. > Is so, what is this doing? When I say "everything it needs", that includes files; APE binaries, AIUI, include some code to transparently read files embedded in themselves, so that line says "run this vim binary, but when it starts instead of reading the user's normal .vimrc (if any), read the vimrc that we embedded in this binary under the virtual /zip path"
- yellow_lead 3y ago> saving backups of files in ~/.vim/backup every time you save, and keeping an undo-per file Is this a security risk? Not complaining, as it can be changed in the vimrc, just want to pose the question.
- cardanome 3y agoFor a file to end up in ~/.vim/backup you need to have (had) the right to edit it in the first place. (I assume) files that are edited as root would go into the root home directory, so no problem. I can maybe see it be a problem for servers but I can't really think of a likely case, you would have to mess up pretty badly.
- tczMUFlmoNk 3y agoOn the other hand, files edited through a flow like `sudoedit(1)` get copied into /var/tmp with mode 0600 and edited under the user's editor. This is in some ways much better than something like `sudo vim`, since that's a lot of privilege to be granting to a large attack surface. But it does create files like ~/.undodir/%var%tmp%shadow.XXcFqVH3: also with mode 0600, but they stick around even after sudoedit(1) terminates. So I think that it's fair to say that it is a nonzero security risk because it creates persistent copies of potentially sensitive files. Aside from just a strict Unix permissions model, I think it's also easy to imagine cases where you create a sensitive file, edit it, delete it, and expect it to be really deleted. Or even just use Vim as a scratch buffer with no name! Yet undodir persists data in these cases, too.
- csdvrx 3y ago> So I think that it's fair to say that it is a nonzero security risk because it creates persistent copies of potentially sensitive files. sudoedit is something I hadn't considered. The backup should have an exclusion list, with at least /var/tmp > Yet undodir persists data in these cases, too. Except showing the count of available backups files somewhere in the interface, I don't see an easy way to avoid that
- ElonsNightmare 3y agothe whole point of vi is no key chording so no carpel tunnel. hard pass, thanks.
- yawpitch 3y agoThe APE part is a lot more interesting than the (highly subjective) configuration choices.
- deleted 3y ago[deleted]
- csdvrx 3y agoI like bash, readline and chording, guilty as charged!
- sodapopcan 3y agoThe whole point of Vim is to configure it however you dang well please! But yes, calling these defaults "sensible" isn't the best idea. You could certainly make a case for some sensible vim defaults, but these ain't it (even though I like some of them).
- juped 3y agoThat's the whole point of emacs; there is no point to vim, then.
- sodapopcan 3y agoThat's not true. For many people Emacs' text editor is the least interesting part of it and use evil mode to get Vim-like bindings. While the jokes may lean on the differences in key-bindings, they are hardly the whole story. Vim is a super lightweight editor that is available everywhere and very easy to carry around your own single-file config. You're allowed to configure it however you want. Vim too has its share of annoying key chords... <c-r><c-g> is one I use often enough that I stilllll haven't made a mapping for (and likely never will at this point).
- amelius 3y agoOne thing that always bothers me. If I open the same file twice in Vim, how can I make Vim take over the other session?
- deleted 3y ago[deleted]
- em-bee 3y agohttps://vimdoc.sourceforge.net/htmldoc/remote.html https://vimdoc.sourceforge.net/htmldoc/remote.html
- jitl 3y agoThis is giving me the idea to check a NeoVim ActuallyPortableExecutable containing my NeovimRC into my Dotfiles git repo. Would be very handy to be able to SCP it to servers in an SSH pre-command & always have my setup!
- krick 3y ago> sensible defaults > a tabline on top I don't have anything against all these "default configurations" for vim (even though I'm struggling to imagine, why the kind of person who doesn't want to configure vim himself would choose vim in the first place), but this line just made me chuckle.
- doix 3y agoYeah, I don't think "sensible defaults" is correct. More like "my defaults". How do you split if ctrl+w is cut word instead?
- csdvrx 3y ago> How do you split if ctrl+w is cut word instead? Before I tell you how, I want to tell you the 2 reasons why I don't like splitting with Ctrl-W: 1) because I think Ctrl-W should the same thing as on readline or emacs 2) because even if existing uses of Ctrl-W were removed from the picture, splitting with Ctrl-W use 3 keys. Why use 3 keys when you can use 2? I like short sequences, and chording, and there are many 2 keys sequences that are free to use if you know where to look for: I prefer to use what can only be done with MOK sequences, because these sequences are more likely to have a degree of redundancy. For example, Ctrl-I duplicates Tab: if you use a MOK you can have Tab do something (indent) while Ctrl-I does something else (jump in the edit history). Ctrl-I is "free to use" without limiting function, because keyboards generally have a Tab key. These are "sensible defaults", because most people do that in other editors. My splits are mapped to MOK sequences (Ctrl-; Ctrl-' Ctrl-\ Ctrl-/ Ctrl-`) but I've thought it may not be a good idea because 1) it's more unusual and 2) I rarely use split in vim so I don't think I can make an educated choice besides having Ctrl-T start a new tab (like it does on a browser), so I've left them out: I've just left the "echo" part. If splitting is important to you, and you want to try out these MOKs, search for "echomsg.*was hit" and bind your windows split around line 256. I would like to know what you think of these. I may trust your judgement more than mine, if only because I don't use splits much in vim. If you think these MOKs does the job for you, and if you think splits are important, let me know and I'll add the split mappings to the defaults for the next release (EOY, it may include a CuteBash)
- reissbaker 3y agoThis is sick and eliminates the "but I want my muscle memory to work on bare-metal Vim installed by default on every Linux" complaint against stuffing too much config into Vim. Why bother using the barebones install when you can just scp a single binary over that contains everything, to literally any OS? Amazing. That being said, the config is definitely highly personal — it would be amazing to have a set of scripts to compile one's own personal .vimrc and related config files (really, the entire .vim directory) into a single APE.
- csdvrx 3y ago> That being said, the config is definitely highly personal I have very special preferences (like CHORDING EVERYWHERE! :) ) > it would be amazing to have a set of scripts to compile one's own personal .vimrc Actually, I thought about people who may have different preferences! If you want to do the same thing but with your own .vimrc, just check the "How can I make my own CuteVim APE?" section in the README (https://github.com/csdvrx/CuteVim?tab=readme-ov-file#how-can-i-make-my-own-cutevim-ape https://github.com/csdvrx/CuteVim?tab=readme-ov-file#how-can...) This section documents the use of the refresh.sh script from https://github.com/csdvrx/CuteVim/blob/main/refresh.sh https://github.com/csdvrx/CuteVim/blob/main/refresh.sh > and related config files (really, the entire .vim directory) into a single APE. I don't like having a billion files everywhere (like plugins/ etc) so I didn't think about that usecase, but that would be a great addition because most people have a .vim tree: even with my dislike for having too many files, I have myself a few in .vim/after/syntax/ (to apply italics to comments) If you can contribute a script that converts your .vimrc and .vim/ tree into something that can be added to the APE, I'd be very happy to add it!
- juped 3y agoIf there's an "m" it's not portable vi and that's a fraud anyway.
- isp 3y agoThe binary was compiled with Cosmopolitan Libc [0], and therefore the binary will execute natively on Linux, Mac, Windows, FreeBSD, OpenBSD, NetBSD, and bare metal (BIOS boot). I would call that portable. [0] https://github.com/jart/cosmopolitan https://github.com/jart/cosmopolitan
- sodapopcan 3y agoHey csdvrx, Have you written anywhere---or would care to expand here---why you have stuck with Vim over NeoVim? I ask because I have done the same. I made a couple of attempts to switch to nvim the last of which was abandon just over a month ago. Just curious! I have a very hard time articulating what I like more about Vim other than simply it just suits me better (which isn't an interesting answer).
- csdvrx 3y ago> why you have stuck with Vim over NeoVim? Wow that's a very personal question! I'll try to answer the best I can! I like retrocomputing and hacking, especially for Christmas: I want to write things I can share, that'll mix old stuff and new stuff, and that will make people smile - call it the spirit of Christmas or whatever. My 2022 Christmas project was to write a web server in perl, exposing the whole C:\ drive, just for fun. perl, vim, bash (etc) are old, so they are stable and available everywhere: other things equal, I think doing the same with neovim might have had less impact. Also I think it's better and more satisfying to make existing tools work the way you want (ex: I want images in my terminal without moving to another terminal!), instead of moving to other tools when your existing tools can't do something you want. I believe it's the true spirit of hacking. > i have done the same. I made a couple of attempts to switch to nvim the last of which was abandon just over a month ago. TBH I never really tried neovim, maybe because I like the start screen of vim? The idea of doing something for orphans may be cheezy, but I really like the message! Also why did you attempt to switch to neovim? I don't feel any limitation in vim. I'd be curious to know why you tried. I felt them in tmux (lack of sixel support) or bash (incomplete history file), but instead of doing the sensible thing such as using zsh within kitty like everyone else, I spent some time to have tmux intercept and transcode sixel sequences into "ascii art" (https://github.com/csdvrx/sixel-tmux/ https://github.com/csdvrx/sixel-tmux/) have bash save commands start and stop time in a sqlite database (https://github.com/csdvrx/bash-timestamping-sqlite https://github.com/csdvrx/bash-timestamping-sqlite) > I have a very hard time articulating what I like more about Vim other than simply it just suits me better (which isn't an interesting answer). I see what you mean. I didn't like zsh when I tried it last time I tried to move to Linux on the desktop. I liked hyprland - it sealed the whole linux-on-the-desktop deal. It "suits me better", but it's new so I think (or I hope?) it's not just by weird interest in retrocomputing that makes me prefer bash+vim to zsh+neovim :)
- toastal 3y ago> PS: If you don't have an OLED screen, don't comment out autocmd ColorScheme * call OLED_Black() around line 1162. Instead, go buy an OLED screen! It's really worth it!! Interesting truth. Vivid colors, best response time, saves power in dark mode, #000 looks amazing (and off-black looks muddied). Honestly I wish we normalized true black themes for this reason.
- juped 3y agoThe annoying muddy-low-contrast meme was popularized on screens which were already low contrast. The people doing it wanted that look.
- neverrroot 3y agoTo quote from their readme: “Overriding dark themes to replace the uggly muddy darkgreys by a pure #000000 black: this is ideal on OLED screens which can do pitchblack and give you a higher constrast” Those muddy dark greys are actually there for purposefully lowering the contrast, to prevent fatigue. It takes a while to accommodate to lesser contrast, but once you do it, you will likely never want the pure blacks back, unless you will also make the foreground colors darker to compensate for it. Regarding OLEDs, I’ve gotten the best 31.5” professional grade OLED display, and sent it back, because of the flickering (due to pixels changing state) in low light/brightness conditions. It got me tired very fast (30 minutes) while working at night. Very happy with a Black IPS panel now.
- teo_zero 3y agoI think you're talking about two orthogonal topics. If the fatigue comes from the difference between foreground and background, it's independent of how "pure" the black is. You can have #000 black AND keep a low contrast between bg and fg, which looks great on OLED screens AND doesn't hurt your eyes. This is anyway very subjective. For example, I feel the widely popular Solarized colorscheme MORE tiring because the low contrast requires more effort to tell the letters apart.
- neverrroot 3y ago
- teo_zero 3y agoTo solve the issue with Ctrl-k Ctrl-u leaving out one char in normal mode, have you considered setting virtualedit=onemore? It's often a sensible option when you want to "unify" the behavior of normal and insert modes (I've not tested it in your environment, though).
- csdvrx 3y agoI hadn't. but I will! I like Ctrl-k Ctrl-u to clear the line, and this leftover character is something I really don't like, so THANK YOU! If you have more suggestions, I'd be interested to know! (the best way might be for you to try to edit files with it for like 10 minutes, to see what's missing from your usual configuration) I'd love hear what different people find missing from CuteVim to make it more helpful and pratical (ex: I leared the sudoedit security issues here, so I'll add a undo and backup exclusion for files from /var/tmp)
- teo_zero 3y agoMuch of your setup is purely personal taste, so I wouldn't feel comfortable to comment on it. I'd just suggest you get rid of some old vim cruft: :set complete-=i :set nrformats-=octal For consistency: :noremap Y y$ :noremap vv V Since you set 'shiftwidth' (4) different from 'tabstop' (8), you should also set 'smarttab'. I'd add j to 'formatoptions' for .c and .h files (or even for all types of file).
- csdvrx 3y agoI've gather information from many sources and removed what I've found to be no longer applicable, but there must still be some cruft hiding! Thanks a lot for your suggestions! I'll prepare a new revision!
- imjonse 3y agoWith the risk of being somewhat off-topic, in this thread I'll be the one bringing up Helix first. As a vim user for 20 years, I tried it out last time it was brought up on HN two months ago. I have been using it ever since and I probably won't go back. Despite my 20 years of vimming I had never really successfully customized it deeply, going with very few plugins and changes. Tried neovim a few times and it is amazing when it works, but the various distros, plugin updates and occasioanal errors made me anxious. If you are a power vim/nvim user who likes tweaking their config and playing with plugins that's great and nvim truly delivers on the Personal Development Environment idea as it is sometimes called. For me, having more things covered almost out of the box (and by installing a few non-Helix packages like LSP servers) in Helix than I ever properly had without issues in vim setups (LSP, treesitter, fuzzy file open, built in keymap help, etc.) is liberating. The only clear downside for me is some of the shortcuts are different (xd instead of dd) but even those can be configured to be more like vim if you wish to. For others no built-in-debugger or git integration may be showstoppers, since those will only be done via plugins when the plugin infrastructure is done. When I heard about Helix a few years ago I was dismissive since it seemed like a pointless rewrite of and editor in Rust for performance or for a more consistent approach to keymappings, both of which seemed good goals but not good enough to switch your editor. The fact that it comes with so many features built in and thus stops the possibility of fragmentation across a lot of dimensions is very reassuring though. I want opinionated tools because I am not that special and neither are my programming tasks that different from other people's. Vim still has a special place in my heart and use it on remote servers. So, sorry if off-topic, but for those who are in similar position - want bells and whistles not just a plain editor, but gets tired by finding and maintenance of many plugins - it may be worth checking out.
- oblio 3y agoNeovim is a bit of a disappointment on a certain front. The devs stated decision is not to deliver an actual editor (up to a point), their focus is on creating an editing component and ecosystem. Which is fair on their side, but it shows in the quality of end-user tooling. For example nvim-qt is quite barebones compared to Gvim (which could be argued to have had too many features... maybe). > Tried neovim a few times and it is amazing when it works, but the various distros, plugin updates and occasioanal errors made me anxious. I have the exact problem as you. I don't even need a ton of features besides the core Vim/Neovim ones, I'd just want stuff I've come to expect from similar editors/IDEs in the past decade, and Neovim doesn't want to bless any of them: - file manager - universal search (commands and files; Ctrl-Shift-P, Ctrl-P) I think it's best to accept that the target audience for Vim/Neovim is a certain kind of person and despite a relative match on many fronts, we're probably not enough of a match for long term use. Oh well.