29 ms·
Why I teach vim
- xenihn 6y agoWould this author happen to have a blog post of how they teach it? I'm curious.
- dreamer7 6y agoYa that would be really helpful. I've picked up bits and pieces of vim over the years. Recently, I even installed vimium on Chrome and the vim extension for VS Code in an attempt to get better at it. It has been quite effortless to delete or replace words or lines but every time I've tried getting more adventurous with it - say, surround every line of text with double quotes etc, I end up finding the commands unintuitive or hard to remember. There's also an issue with my older muscle memory of `CMD+Z` which works on a different stack than `u` and `CTRL+R` and I end up messing up my code.
- Lio 6y agoI guess I’ve got used to working with both sets of shortcuts but I miss the Vim undo system in other apps. It’s worth noting that u and ctrl-r don’t operate on an undo stack but on an undo tree. So if you have a series of edits and undo them all then do something else you can still get back to where you were before. Use g+ and g- to walk the tree and the Gundo plugin is gives you a nice visual diff interface. So having a separate shortcut and “stack” is actually a great feature of Vim IMHO.
- dreamer7 6y agoWow I didn't know about the undo tree! That would have definitely helped in a few scenarios
- xenihn 6y agoThis is really cool, and I had no idea about Vim using a tree instead of a stack for undos. I'll check out Gundo. Do you have any other similar recs that would help for learning?
- apocolyps6 6y agovim generally doesn't need any of those fuzzy file finders that most people use. If you add set path+=** to your vimrc, and open vim from the top level directory for your project :find <unique_filename_part> will just work Setting up ctags will give vim some IntelliSense-like functionality that people tend to miss from their IDEs. More info here: https://andrewra.dev/2011/06/08/vim-and-ctags/ https://andrewra.dev/2011/06/08/vim-and-ctags/
- gbrown_ 6y ago> vim generally doesn't need any of those fuzzy file finders that most people use. If you add > > set path+= Be wary of this, it can end up being quite slow. Here is an excellent write up detailing the usage of the path setting. https://gist.github.com/romainl/7e2b425a1706cd85f04a0bd8b3898805 https://gist.github.com/romainl/7e2b425a1706cd85f04a0bd8b389...
- Lio 6y agoDrew Neil’s vimcasts.org is a mine of useful tips. His book Practical Vim[1] is particularly good because it teaches you the “vim way” without plugins. Not that there’s anything wrong with plugins, I use a load of them, but there’s loads you can do without them. 1. https://pragprog.com/titles/dnvim2/practical-vim-second-edition/ https://pragprog.com/titles/dnvim2/practical-vim-second-edit...
- gbrown_ 6y agoNot sure about the article in question but I would highly recommend ':help user-manual', it's actually mentioned at the end of vimtutor. It can be worked through chapter by chapter and covers all of Vim.
- Geminidog 6y agoI really wish there was a batteries included vim-like console editor with all the power of the jet brains suite of IDEs and convenience and lightness of vim. As it stands right now I end up using both an IDE and vim. Maybe emacs is the answer but honestly if I look past all the yak-shaving to get emacs to the power level of an IDE does it really get to the point where it has everything that say CLion has?
- deleted 6y ago[deleted]
- tikhonj 6y agoI'm not sure about the specifics, but providing something a lot more "batteries-included" seems to be the idea behind Emacs distributions like Spacemacs and Doom Emacs. One difficulty is that language-specific tools (language servers, linters... etc) are standalone pieces of software with their own dependencies, requirements... etc. It's hard to bundle together a fully "batteries-included" Emacs without figuring out a way to manage native software and services. I think this is one place where Nix can be a real advantage: even if you don't care about Nix's reproducibility, it's ability to manage Emacs, Emacs packages and language-specific tools is pretty unparalleled. If I had some more time on my hands, I would try putting together a Nix-based Emacs "distribution" with some easy way to configure which languages you want to work with. Coupled with lsp-mode and language-servers, this has some real potential!
- jolux 6y agoEmacs mostly has problems with external language servers because its plugin model is archaic and brittle to a large extent compared to that of say VS Code. It's also far more flexible but with power comes responsibility, and I've found Emacs extensions far more likely to interfere with each other than in less composable editors. You don't need Nix to fix this problem.
- Geminidog 6y agoGiven the brittleness there should be at least a single configuration that works. I believe that tikhonj is right in the sense that nix can capture this configuration. Nix is not required but I can see how it can help.
- fergie 6y ago"I wish I could say I agonized over all the options at the time and decided vim was the best pedagogical solution, but the reality of the situation was that vi was what I used in college because my father taught me vi" We dont talk about this much, but many of us hardcore Vi/Emacs users have had this knowledge imparted to us from a mentor. Thats probably why the use of Vi/Emacs is much higher in established tech environments (universities, big dotcoms), where there tends to be a tradition of mentorship than it is elsewhere. If anyone is looking for a slightly off-the-wall masters thesis, I'm fairly certain that you could extrapolate this out into a class divide- perhaps richer/more-established/well-educated users are proportionally more likely to use Vi/Emacs, and in some ways use them as "gatekeeping" tools?
- scruple 6y agoMy mentor was a humble man from the Turkish countryside. He held dual masters in EE and CompEng. He knew vi because what else would he possibly know? It's what he learned in university. And, so, he taught me what he knew. I've mentored about 2 dozen people and I've taught them all vi(m). As far as I know, though, it's only stuck with 2 or 3 of them. C'est la vie.
- pvg 6y agoThey're not really the same thing, compared to vi[m], emacs is statistically dead. And there are already lots of people who're well into their careers in academia and industry who aren't users of either. My own contrarian and probably equally wrong take is that it's mostly about accepting the (evidence-free) premise that modal editing is actually a good thing. It's hard, you suffer but lots of smart people tell you it's worth it and perhaps your suffering will help you be as smart as them. It ends up being closer to hazing and penance (your editor as hairshirt) than actual gatekeeping.
- rgoulter 6y ago> it's mostly about accepting the (evidence-free) premise that modal editing is actually a good thing. Kakoune's development has started fairly recently. The oldest tags on its GitHub repo are for 2018. I think this defies "people want to continue the legacy of actually-not-that-great thing because I had do suffer, so other people should too". I think you'd only put into making/promoting Kakoune if you genuinely thought modal editing is a good thing. Whereas, if the bigger value in "I learned modal editing" is the signal of "modal editing is hard, so anyone who knows it must be good" (rather than value from a better developer experience), I think aiming to make modal editing more intuitive/accessible is counter-productive.
- saagarjha 6y ago> I always tell my students that the one editor they are likely to find already installed on a machine is vim Well, vi, since it's part of POSIX. Unless you are fine with ed ;)
- arendtio 6y agoI am quite surprised to learn, that vi is actually part of POSIX. I mean that is pretty cool and wonder why someone would down-vote that comment?
- cweagans 6y agoIn many (most?) modern distros, vi is a symlink to vim.
- bch 6y agoI think all BSDs (net, free, open, dragon fly) use honest-to-goodness nvi[0]. Of course vim is available as an installable 3rd party piece of software. [0] https://en.wikipedia.org/wiki/Nvi https://en.wikipedia.org/wiki/Nvi
- Lio 6y agoThere’s a vi clone in Busybox too, which whilst not Vim, is still really useful.
- reidrac 6y agoBack at Uni I used joe because I was used to WordStar (DOS). On one of my early jobs I had to telnet to an AIX machine to do some work and, of course, joe was not installed and vi was. I had almost no idea on how to use it, and by the end of that project I had decided that I needed some vi skills!
- cupofcoffee 6y agoI used vim for some time could never really get into it. The benefits that it offers over other simple code editors like TextMate isn't really worth the learnign curve. It pretty much feels like a mini programming language for text editing.
- arendtio 6y agoI'm not so sure about that. Yes, I have the hard part of the learning curve behind me, but learning vim actually changed how I write code in a very positive way. Now, I think a lot more in terms of lines and e.g. rogue whitespaces happen rarely. I know that are tools who can remove them, but I want to illustrate, that the editor improved the quality of what I type. In the end, it depends how much time it will cost you to learn vim and if that is worth the effort and I am honestly not 100% sure, but I wouldn't want to go back to how the world was before.
- pampa 6y ago> In the end, it depends how much time it will cost you to learn vim Is there really that much to learn? Open file, save file, exit, block select, copy paste, search and replace - thats about 99% of what you do in an editor. 15 minutes to pick up, ipossible to unlearn. Unless you have some other editor ingrained in your synapses. Switching between editors with different shortcuts is a torture.
- arendtio 6y agoActually, the commands you listed are more or less the basics, but the magic comes when you learn about the structure of the commands. For example, `2dw` is a typical example. So you start with the number of times you want to do something, then you add a verb like `d` for delete and you end with a noun like `w` for word. As you probably have guessed, it deletes the next two words. Since working with lines is quite common, many commands are executed for a line when you repeat the verb (easy to type). So `2dd` deletes the next two lines. When you use this language you start using vim. There is still more to explore (e.g. macros), but this is where vim is different.
- Rainymood 6y agoWhy I started to use Vim 5 years ago. I was coding a lot and I realised most of my work was editing code as text. So I figured, why not become really freaking good at it? Vim has a steep learning curve because it's a mental paradigm shift. I personally would recommend it to everyone because although no-code is taking off, most of the developers are still editing text. Sharpen that saw!
- apta 6y ago> no-code is taking off I don't see any evidence for that.
- mxuribe 6y agoThere are many aspects underlying digital transformations that large enterprises are undergoing...among the many, is to empower more "citizen developers" with tools that are lower-code and no-code. (I'm not convinced that no-code is a great thing just yet...but not because of the tools, rather the mindset...so we'll see how the next generation adopt these no-code tools...or not). Within these transformations, the premise of "no code" is becoming bigger and more popular...so if you're not seeing it yet, you will soon enough more and more. Not that my following note is a large representation, but when i was applying for a new job during latter 2019/early 2020, over 90% of the jobs that i applied to made mention of some sort of "digital transformation", and no-code/low-code goes part and parcel with those types of efforts. Again, low volume of data, and biased towards mid- and large-sized enterprises...but, it is a thing for sure.
- ensiferum 6y agoYou shouldn't be editing "text" but "code" however. Text editing is low productivity task whereas code editing should happen mostly be at much higher level.
- beny23 6y agoThe ability to efficiently navigate and edit files while SSH’d into an instance is a very useful skill. You just wouldn’t have the permissions to install your favourite editor and vi is almost everywhere. I had to learn vi when working on green screen terminals logged into HP/UX and there was no alternative but am very glad I did as I find that nothing as ubiquitous allows me to efficiently change files. Does that mean I would go around advocating one editor over another? No, whatever works for you. I know vi works for me for editing files. Would I use vi instead IntelliJ for development work? No, I found the development environment allows me to be more productive on project work. But I think you’re doing students a favour teaching vi.
- maccard 6y agoI've been a professional developer for 10 years and programming for longer than that. In all of that time, efficiency of editing files on a remote server has never been something I've needed to optimize or been concerned about. Have I had to do it? Yeah, occasionally. Yet when I do, it's almost always changing a config file in a minor way. Back when I started it was editing the code on a live server so I used textwrangler/notepad++ with an ftp editor. I don't buy the argument that learning an editing paradigm for this very specific use case (which is likely getting less and less common) at all. This is coming from someone who uses vim bindings in my daily editor.
- kdtsh 6y agoDepends on what you need to optimise for. Being able to navigate a text file efficiently (i.e. not character-by-character using arrow keys), cut and paste text, save/rename/backup files, and sometimes even to do a diff from within your text editor, are all skills I’ve found very useful. I’m an Emacs user on my own desktop, but if you run Linux servers in this kind of environment and you or your team doesn’t manage them yourselves, then the best you can assume you have is Vim, or maybe Vi. If all you’ve got is SSH, it helps to be able to do this stuff without wanting to pull your hair out. Even watching some co-workers stumble through the use of Vim can be painful enough.
- beny23 6y ago
- afarviral 6y agoI wish there was a dedicated, light text editor that could be comfortably used as a typical vim config but was fully compatible with a windows/mac paradigm for discovering shortcuts or standards (e.g. with the mouse or using standard keybindings). Gvim isn't quite there but close. This fictional editor should still be usable by anyone in a terminal but should be used like vscode as a standalone tool and yet very, very low resource, low fuss. There just isnt such an editor. Vim itself is just too hard for a beginner. It took me far too many years to know it and Im still learning years later...but I'm hooked now and struggle to edit text using the mouse, end, home, delete, enter, tab and ctrl-chords. I'd recommend it to anyone but more as a fun learning project; an esoteric plaything with real-world applications that give you a bit of an edge oftentimes.
- deleted 6y ago[deleted]
- RMPR 6y agoonivim.io
- mettamage 6y agoHere's why I taught vim to students (at a coding bootcamp, in 2017). - vimtutor does all the work for you. - Like the author says starting up and editing with vim "just works". When I "teach" vim, what I'm really doing is grading their homework. After their vimtutor hour, no student asked me how to edit git commits. I know it might seem lazy (it is), but when there's a teacher better than you, don't teach it yourself, delegate. I happily delegate to vimtutor. Miss or mister vimtutor, you're a better teacher at vim than I will ever be.
- rStar 6y agoi only had one good teacher in high school and I consider myself lucky. the students of the writer of this article have at least one good teacher as well. personally i only know vim enough to know that I prefer emacs, but I agree with virtually every point of this article. a further point I would make is when you learn these technologies(a text editor/cli/unix tools), you will literally use them for the rest of your life. With no subscription fee!
- amagumori 6y agoMore so than even the choice of editor itself, I think the biggest argument for vim or emacs, especially for students, is that you “live in” the *nix cli. The amount of stuff you soak up being a unix tool user is just night and day compared to using sublime text or something. Because using a cli text editor implicitly sets you on this path of learning through the command line. So you start with cding and lsing around, opening your file in vim, typing gcc or whatever. In a very frictionless and natural way, pretty soon you’re reading man pages, writing shell scripts and makefiles, etc. In a very real way, the Unix command line environment has you poke around an interactive “boiler room” of your computer, and that type of learning, learning by exploration, is something far different from learning individual tools at a higher level of abstraction. It’s like letting a kid loose into a master’s workshop instead of showing them one tool at a time. By seeing everything “together” and exploring what the different tools do, the “fog of war” of unknown unknowns clears much faster for a novice, and this provides a MUCH more solid knowledge footing to build on.
- notsureaboutpg 6y ago100% agree with this sentiment. As a student, using emacs was part of the big push to get me to live in the cli and explore and love that world. Now I use graphical IDEs, and all sorts of tools, but I appreciate the power of cli and am not scared of it (and I went into college being almost computer-illiterate). That foundation is key and very important
- tomhoward 6y agoI'm a Vi/Vim user since 2000, when I started transitioning from my ISP junior tech support job into a corporate support/sysadmin job. Vi was what everyone used, so that's what I was taught. I was just shown the basic 5-10 key commands, then I was on my own. Life got a whole lot easier when I invested about $15 in a Vi cheat sheet coffee mug. Never looked back.
- bitcoinmoney 6y agoLink to the cheat sheet and coffee mug?
- elygre 6y agoGoogling for “vim coffee mug” provides reasonable hits.
- mandelbrotwurst 6y agoYeah, it might even return many similar products of varying quality, which is likely why the person you're replying to is asking which particular one they found useful.
- hotsauceror 6y agoThe second hit includes a CafePress mug where the keyboard navigation diagram is wrong. So maybe they’re not all equal. https://www.cafepress.com/mf/54286678/hjkl-vim-navigation_mugs?productId=535185295 https://www.cafepress.com/mf/54286678/hjkl-vim-navigation_mu...
- tomhoward 6y agoHere it is [1]. I just found it in the back of my crockery cabinet! Looks like it's stayed in amongst my possessions for the nearly 20 years since I got it, through several house moves and stints in storage. It's going back on my desk now. I can't find any the same as this when searching for it online now, but this seems the closest [2]. I like the simple text design much more than the coloured keyboard layout [3]; much more in keeping with the vi ethos. [1] https://www.dropbox.com/sh/ngj8wt96ld1di0q/AABcpi8fuQ9hUkIP-2hz-0Wda?dl=0 https://www.dropbox.com/sh/ngj8wt96ld1di0q/AABcpi8fuQ9hUkIP-... [2] https://www.cafepress.com/mf/10388170/vi-reference_mugs?productId=11507711 https://www.cafepress.com/mf/10388170/vi-reference_mugs?prod... [3] https://www.zazzle.com.au/vim_cheat_sheet_coffee_mug-168614566572345975 https://www.zazzle.com.au/vim_cheat_sheet_coffee_mug-1686145...
- paradox_hunter 6y agoWhat most people forget when they argue against learning vim is that vim is more that just a text editor, it's a whole new philosophy. Once you learn it, you can find it almost everywhere. Learning vim key-bindings was the first thing I did after learning to touch-type, and now I use the same key-bindings on VSCode, Intellij, a remote server I am SSHed into and with the help of Vimimum, even chrome! And if ubiquity isn't enough, then I would point you to this article which does an awesome job explaining the really idea of vim, composability. https://medium.com/@mkozlows/why-atom-cant-replace-vim-433852f4b4d1 https://medium.com/@mkozlows/why-atom-cant-replace-vim-43385...
- archgoon 6y agoUnfortunately, vim macros don't tend to get implemented when other editors implement keybindings. This is unfortunate, vim macros are fantastic for reformatting text.
- dfinninger 6y agoMaybe not all of them, but you can use macros in IntelliJ and VSCode implementations (and, of course, Emacs).
- pkulak 6y agoExactly this. Vim is special because it's what we've all agreed on as a standard for modal editing. Luckily, it's also pretty darn good, but that's secondary. Learning one set of commands that can then be used across editors, operating systems, and even terminals is amazing.
- thomastjeffery 6y ago> Vim is special because it's what we've all agreed on as a standard for modal editing. Well I didn't vote for you... In all seriousness, Vim's keybinds are only popular because no one has really tried to make a good modal editor with different bindings. It's prohibitively difficult to change the bindings in Vim, and prohibitively difficult to change muscle memory, but I still wish that I had a good modal editor that didn't resemble Vi. It's a similar story with keyboards and qwerty.
- Nginx487 6y agoIn early 2000th I used to admin quite diverse network, including rare and exotic *nix systems, early Sun machines and HP-UX. One thing I was sure about - every of them had 'vi' after installation.
- magoghm 6y agoI learned to use vi because it was the only full screen editor available in the Unix machines I was using in 1983. At that time, I occasionally still used ed for simple edits because I didn't want to wait for vi to startup :)
- vulcan01 6y agoI started programming about 5-6 years ago (I'm a high school student). I started with VSCode, but about 1.5 years ago I switched to Vim for the simple reason that I wanted to live in the terminal. Unlike some other commenters here, I didn't know anyone else who used Vim (or Emacs for that matter), so I learned on my own... (:help is actually good in Vim, unlike many help menus in other software). vimtutor does a great job introducing vim, and it took me about 1 hour or so to get started.
- jez 6y agoI have a pretty similar story. I was in senior year of high school and one of the colleges I was applying to had a “sleeping bag weekend” where you could sign up to stay overnight with a random CS freshman in the dorms and stroll the campus. I saw someone working on their homework and their terminal had colored text and it blew my mind (I had only ever seen cmd.exe using black and white with that ugly font). The summer between senior year of high school and starting college I installed Ubuntu and googled that program called “vim” that freshman had demoed to me. From there it was just like you say: vimtutor and reading :help pages, and now almost 10 years later I can’t imagine trading Vim for anything.
- waffletower 6y agovim is not for everyone. The cartoon poking fun at Emacs chording doesn't resonate with me at all. The statefulness at the core of Vim is maddening for me, where Emacs chords, perhaps because I have been a musician, are relatively easy for me.
- kazinator 6y agoI switched to Vim in 1994. At that time, I had been using Emacs for a bunch of years. One day I decided to cross over to the other side. I hunted down all the readily available open-source Vi implementations, downloaded them and compiled them all. I tried Elvis, Nvi, Xvi, Vim and a couple of others I don't remember. Vim was the best, by a long stretch, so I continued with that. I found the built-in tutorial very handy; I went through that, and within a week I was proficient. A couple years later, I started seeing Vim in GNU/Linux distros as the default Vi implementation.
- hvasilev 6y agonoone cares what editor you use, text editors have marginal impact on the product or service that you are developing.