Why, oh why, do those nutheads use vi? (2007)
viemu.com
viemu.com
foo bar baz
And you need each line transformed into:
[Foo](https://example.com/foo.html)
Or something like that. Macros make short work of it.
(Personally, I find vim's multiselect cumbersome to use compared to sublime/vscode's.)
Reiterating point 3 from the article: e.g. if the cursor is at | in:
printf("Hello |World\n");
With vim, you could manipulate the text in different ways by using different motions, e.g.:`db` would give `printf("World\n");` (b for backwards),
`de` would give `printf("Hello \n");` (e for end-of-word),
`di"` would give `printf("");` (inside `"`),
`di(` would give `printf();` (inside `(`),
or instead of deleting, some actions could be useful, like changing to uppercase: e.g.
`gUi"` would give `printf("HELLO WORLD\n");`
I always at least whip through such articles about vim as there may be something I don't use daily, but could. There always is such a thing.
I love to use all the zero-configuration things that are already present in Vi/Vim at work. IDE's are cool for devs or people who do everything from a stable workstation. I rarely have such comfort, jumping from one server to another, from one image to another. And Vi or Vim are always there. Thanks for all those hints.
ctrl+backspace: `printf("World\n");`
ctrl+delete: `printf("Hello \n");`
alt+shift+right, alt+shift+right, delete: `printf();`
I keep trying to get into vim
Speaking out of my 20 years experience, you probably shouldn’t. You’ll find vim a little behind sublime/vscode in some parts and will keep trying to get out of it, unsuccessfully. I came to conclusion that I wish all of the editors (vim included) separated editing from their operation and made it modular (vim-like extensions are limited to a subset of it and are really worst of all these worlds, cause only half of your habits work and none of your scripts/addons do).
Edit: please don’t downvote the parent commenter, it’s a non-obvious knowledge and it doesn’t apply to everyone.
Edit: I spent a long time trying to make Vim more IDE-like, but found it was more productive to make my various IDEs more Vim-like, but I concede that might not be suitable for everyone
I wouldn't use this as the basis of an argument for superiority of IDEs in general over vim.
And of course there are tradeoffs, rubymine users I worked with always complained about startup times and heavy indexing. (This was a few years back, maybe it's improved since)
If you can write vim macros to extract method, push up dependencies etc, then you've made vim better than most IDEs.
It's true that there are a lot of things I configured specifically in vim, however, VSCode has a pretty decent vim mode that takes care of a lot of stuff (including a bunch of pretty standard stuff that most people add to vim, like adding vim-surround for example).
In addition, it has a pretty decent way to configure new commands, so most of the other stuff I missed from vim I could actually figure out how to port over to VSCode.
Totally worth it for me - it was a few months of slowly rebuilding habits and porting commands from vim, but now I have a "best of both worlds" setup.
It starts faster, everything works together better, no weird plugin-compatibility issues (mostly). If I need to find a command, it's easier to lookup in VSCode than Spacemacs (because the menus use a much better GUI, with fonts, highlights, etc).
If I want to switch between files, open a folder as a project, etc, it all works well, and out of the box. With Spacemacs, there isn't a good file-tree pane that I can put on the left - IIRC it comes with something like NERDTree from vim, but it never worked well for me. Partially this is the whole fonts/gui/etc limitations, partly it's because a lot of the shortcuts just don't work that well. Just quickly opening up a folder, seeing what files there are, and being able to rename a file by right-clicking on it and hitting rename is something that I don't do often, but happens once a week, and in Spacemacs, that once a week necessitated either looking it up, or fixing something.
(I was faster at doing these things with vim, in which I had way more time invested, but why I switched from vim to emacs is a similar story in many ways.)
Honestly, overall, VSCode and modern IDEs are just a much smoother, better overall experience in so many small and large ways, that I feel I am much more productive, and have to spend way less time tinkering with my editor. And much as I love to do that, I've been doing it for 10 years, and already have a decent set of knowledge about what I need and want. Getting it practically out of the box with VSCode, and having it work better, is a wonder.
(My biggest block in switching to a different editor in all this time was that I had to have a decent VIM mode, because being able to actually edit text at speed and comfort is more important than all the other features to me. But once I realized that Spacemacs' vim mode was decent, I switched to that, and then I played around with VSCode and realized the vim mode there was decent too. Definitely enough to satisfy 95% of standard text editing use cases, with either plugins or my personal mappings making up the gap.)
From the sounds of things you're used to discovery by context clicking and menu items, and emacs' lack of such things does hurt discovery. I find the mnemonic key mappings in spacemacs to be superior to those interactions, but I'll admit: only if you can actually find them, and it does take some time to get used to the conventions.
As a developer though, I am an expert in using my editor, so I'm happy doing e.g. ",tt" to run the test where my cursor is, ",tb" to run all tests in a buffer, etc. because that knowledge pays off hundreds of times a day.
Lastly I'm not sure the distinction "modern IDE" is helpful. Neo/vim and emacs are both under very active development. Useful variables seem to be things like: package ecosystem, UX, aesthetics, responsiveness. All of those can be divided into beginner/expert and IMO emacs wins all of the expert cases, _if you are willing to put lots of time in_. For example I'll take my beautiful full screen spacemacs with the bells and whistles turned on over the looks of my colleagues' VSCode any day.
"Willingness to put the time in" of course exists in a continuum. I know fantastic programmers who gave up on the effort of emacs, and others who tell me that I'm selling myself short by stooping to spacemacs instead of rolling my own. So everyone's MMV.
I half agree and half disagree. I also really hate having the mouse involved in my workflow.
> From the sounds of things you're used to discovery by context clicking and menu items, and emacs' lack of such things does hurt discovery.
That's part of it, but not all of it. I don't use context menus much and am also a keyboard-centric user. I rarely use menus for any common tasks.
That said, things that I do once a week, but do need to do, are often easier to do using a mouse (or rather, it's good that a better discovery mechanism exists for them).
> Lastly I'm not sure the distinction "modern IDE" is helpful. Neo/vim and emacs are both under very active development.
That's true, but that's not what most people mean. I think the 'modern' comes in in terms of UX, or at least that's at the root of things - because almost everything can be done with vim/emacs, except for fundamentally changing how they look (different fonts/colors/etc). Or changing the under-the-hood stuff (like running parallel processes).
> For example I'll take my beautiful full screen spacemacs with the bells and whistles turned on over the looks of my colleagues' VSCode any day.
I mean, obviously this is subjective. But GUIs that allow a full range of colors/sizes/etc, and are not limited to only being text buffers, do objectively allow you to do more things. And it's no coincidence that almost all IDEs/editors don't use a single font size everywhere, etc.
> "Willingness to put the time in" of course exists in a continuum. I know fantastic programmers who gave up on the effort of emacs, and others who tell me that I'm selling myself short by stooping to spacemacs instead of rolling my own. So everyone's MMV.
I mean, I used vim for about 8 years, including writing (personal use) plugins and having a very large .vimrc. I then switched to spacemacs, had a bunch of configurations there as well.
So I feel like I've definitely put in a decent amount of time getting "good" at vim (and to a much smaller extent, spacemacs).
Still, putting aside the pure text-manipulation aspects of vim productivity, just launching VSCode and opening a folder gets you way more of the way to productive coding than everything I managed to roll out using a vimrc (and does't break every time I change language/computer).
if I want to do something like filter things in the problems pane, I need to focus an entirely separate thing with no vi bindings so I'm forced to reach for the mouse to use that or even to just get back to a pane that supports vi bindings.
also ctrl+w closes tabs instead of being a prefix for focusing different panes
Lately I've switched to a programmable keyboard, so my actual arrow keys are int accessible via a special Layer (I hold a thumb key, and that gives me hjkl, as well as various other bindings I've created that act like vim commands).
Update: I guess your complaint is about a plugin ecosystem that doesn't respect vim bindings. I think you'd be impressed by what the evil community has, speaking as a former power vim user whose emacs setup is even better.
I'm on spacemacs which I believe has given me a massive head start on a great setup. If I started from something more lightweight I would have wanted to end up where I am now, but the results on my own would have been worse.
However I admit that even the supposedly beginner friendly spacemacs still has the same problem of "find the intuitively named spacemacs layer, then start googling all the package names mentioned in the docs (which are not intuitively named), and possibly read the source", which is a big set of hurdles.
foo(aa, bb, c);
foo(d, ggg, hh);
foo(iiii, i, jjjj);
I want to do something to the 2nd argument on each line. add a fn(prevContents). So I search for "foo(" and then pick "put a cursor on every match". Then how do get to the first comma and the select to the second comma on each line? This is easy with vim, easy with keyboard macros, not easy with multiple cursors (that I know of). For example as soon as I press "find" so I can search for the comma I lose multiple cursors. Maybe there's a special "Search with multiple cursors" command but if so that just highlights the issue, you shouldn't need special commands, you should be able to combine existing commands. vim and keyboard macros make that easy.What I'd do is this: Put the cursor on one of the calls, then use ctrl-d to put a new cursor at all the matches. Then use ctrl-right-arrow to move by word until the second comma, combine that with shift to select the argument and edit all of them with visual feedback to my heart's content.
In reality, depending on the complexity of the text, after creating all the cursors, I'd probably use the vim movements to get them to where I need though.
C-f, "foo\(" [open a Find dialog]
C-Enter: [foo(]XX, YY, ZZ); [Find All shortcut]
Right: foo(|XX, YY, ZZ); [move to the right side of the match]
C-Right: foo(XX|, YY, ZZ);
C-Right: foo(XX,| YY, ZZ);
C-Right: foo(XX, YY|, ZZ);
C-S-Left: foo(XX, [YY], ZZ); [select leftward]
I suppose that it's not quite as ergonomic as Vim keybindings, but it's definitely less of a departure from the usual OS text boxes.I switched to Vim from Sublime Text years ago, and honestly multiple cursors and the live search and replace (especially across multiple files) were both missed until I learned how to do them in Vim just as easily.
Vim is a multi-year investment, and isn't worth it for most people.
- multiple-cursor: select non-contiguous pieces of text, then edit them all at once.
- vim macro/repeat: edit a piece of text, and repeat on similar occurrences.
The vim "way" could be, `/;$` to select the trailing semi-colon, then `cgn` to edit it (enter the curly block once in insert mode, then exit with `<Esc>`), and now you can repeat on the next trailing semi-colon simply by hitting `.` (dot).
So, instead of first looping on the occurrences to get multiple cursors, then do the editing, you first do the editing on an occurrence, and you loop on the editing. There is admittedly less of a "wow" factor, but I don't think it is any less powerful.
(edited for formatting).
I say this as a huge vim advocate, who used vim exclusively for 8 years before switching to emacs and lately to vscode.
Vim gets a lot of things right, and there's no comparison to using vim-style editing. But multiple-cursor editing is a killer feature that really does improve your workflow a lot of the time. Luckily most editors have some version of it now, though often not as good as the original and doesn't always play nicely with the various vim modes.
It implements multi cursors in vim and combines it with vim movements etc.
(I actually tried to implement my own multi-cursor plugin in vim, and got a decent amount of the way there before realizing my fundamental approach probably wouldn't work.)
But the way I use my editor is that I'm usually in it all day. Both for editing code, but also for personal notes, etc. So it's on all day and I spend most of my time in it.
This effectively means I have one tool that I mainline. I'll still use vim in the odd situation where I can't use my main editor, but it's usually just easier for me to open files in the editor I already have open.
I wish there was a NeoKak that would integrate with other environments like VS Code the way NeoVim does.
Why, oh WHY, do those #? nutheads use vi? - https://news.ycombinator.com/item?id=18582221 - Dec 2018 (23 comments)
Why, oh WHY, do those #? nutheads use vi? - https://news.ycombinator.com/item?id=14153147 - April 2017 (1 comment)
Why, oh why, do those nutheads use vi? (2007) - https://news.ycombinator.com/item?id=9362786 - April 2015 (126 comments)
Why, oh why, do those nutheads use vi? - https://news.ycombinator.com/item?id=3542507 - Feb 2012 (220 comments)
Why, oh WHY, do those #?@! nutheads use vi? - https://news.ycombinator.com/item?id=151637 - April 2008 (52 comments)
I don't do anything too sophisticated with it (after 13 years, I still navigate with the arrow keys), but I do keep my .vimrc in version control. Highly recommended.
Vim is a language for keyboard combinations, with a full grammar that contains subjects, objects, adjectives and verbs (e.g. df2m means delete until you find the second m occurance).
Emacs on the other hand allows to flexibly bind as much as you want on each keystroke or key shortcut, which is a completely different concept.
I don't favor vi over emacs. I don't give a damn what you use, use the tool that makes you the most productive. Vim helped me to reflect on my own inefficiencies and taught me how I can optimize my own workflow. And this also applies to emacs users.
If the most efficient tool turns out to be notepad++ for you - I don't care, as long as you're happy with using it. There's no point trying to convince others to use a tool if it doesn't reflect or optimize their workflow. If they don't see the need, they won't be able to appreciate it either (yet).
I'd recommend this SO answer (https://stackoverflow.com/a/1220118) and this series of articles "Vim from the ground up" (https://thevaluable.dev/vim-beginner/)
I'm also writing a reference guide (https://learnbyexample.github.io/vim_reference/)
But maybe that's just because I'm not good with those editors. :)
I once asked my dive instructor about the debates surrounding various dive gear setups. He said, "Strive to be an excellent diver with any gear."
I’ve heard of an editor that can be used with two mice.
I'll use it for months at a time, tell myself it's the editor for me, then go off it.
Not sure what sort of time commitment is needed, or if it's just the wrong editor for me.
Like I tried eclipse, but it was laggy. I tried Notepad++, but it is too GUI. I tried VSCode but getting it to be much better than vim requires tracking down a bunch of questionable extensions or the cool extension everyone is buzzing about doesn't have FORTRAN support.
I dunno. I use vim. I don't like vim. I don't like any editor. It is there, it doesn't do what I want it to all the time, but it reads and writes files, autocommands are easy to set up, and I can just plop whatever unix commands I want in there. vim is pretty boring and basic, but I go back to it because it doesn't do anything actively annoying to me.
What makes me happy to use vim is the odd few hours here and there in visual studio with a large project loaded.
Nano (and before it, pico) work better for me in 80% of use cases where I need to just edit text.
On windows I can use notepad++, which is probably the best win32 text editor in existence, bar none. Between it's plug-ins, and powershell (albeit with a hammer like coaxing), it's just about as powerful as the Unix environment.
I believe vim is a great editor for the kind of people who like sed, awk, and working from/with the shell, since it's pretty much the same culture.
bool ProcessFunkyParam(int nitems, bool properly);
bool RecallClunkyItem(bool displace):
bool DisposeOfAllParams(int ntrials);
This example is nice for I have used vim often if I have to look after servers, and I agree this is really nice.In an VSCode or an IDE however, this is just as easy or easier:
- <End> to get to the end of the line
- shift + alt + <arrow down> twice to get to enable block editing and get a cursor on the end of all three lines simultaneously
- backspace once to delete all semicolons
- type <space> and one { and <enter> to get at new line, you'll also get the closing curly brace on a line below and your insertion points will be on the starting point for all the three new functions we created.
Example 2:
if (!entry.used && equivalent(entry.key(). qk.key) && (curcontext & entry.contexts))
Here I just- get my cursor anywhere inside the expression in question,
- press ctrl + alt + v for extract variable
- and IntelliJ pops a dialog that gives me options for how big chunk of the expression I want to extract. As I move between the options using my keyboard it highlights the expression.
- when I select it IntelliJ already creates it as a value on the line above, complete with a temporary name based on its content. The name is selected already to rename and if I type something else or accept it, it renames it both in the declaration and where it was substituted immediately.
So vim loses before his example even starts, because it takes much more to select functions, copy them, switch to implementation, find a place and paste.
If people want to use vim and to use git only by cli, by all means, but if we could stop the cult like part of it that would be nice.
Same goes for telling students who are learning Java for the first time that it is smart to start with plain Notepad and javac.
Starting to program should be encouraging, not a hazing ritual.
It's not to say it isn't a bit quirky, but it is to say the tool you know how to use is far better than than one you don't.
Same applies to Emacs, first touch on DG/UX, although I was on the XEmacs side of the fence and it was my main programming editor until around 2005.
Both of them were a cruch for lack of proper IDE tooling on UNIX clones, thankfully those days are gone and I don't miss having them as my only option to work on UNIX clones.
:wa|:!kill -9 $PPID
I remember a non-Linux friend of mine having a really poor introduction to Unix/Linux because he got bogged down in learning vi in addition to Unix's other foibles!
Check:
https://mobile.twitter.com/vasudevram/status/128967614667035...
It's a vi quickstart tutorial that I created.
From the start of that Twitter subthread:
[ Those new to vi / vim, hit the ground running with my short vi quickstart tutorial here:
https://gumroad.com/l/vi_quick
I first wrote that tutorial at the request of a couple of Windows system admin friends of mine (at a company where I worked earlier), who were tasked with managing a few Unix boxes, without knowing Unix. They used the tutorial and later told me that it helped them to quickly start using vi to do their work on those boxes, including editing config files, simple shell scripts, etc.
Edit: Since vi is mostly a subset of vim, the tutorial works for vim too. ]
I still love it as a pure text editor, but for code, I've gone to an IDE and don't see myself returning.
nmap Tl :tabnext<CR>
nmap Th :tabprev<CR>
nmap Tn :tabnew<CR>
in my .vimrc, to make it more convenient to work with multiple files.As far as I'm concerned, as a grey beard sysadmin, I don't need an IDE, so I value more the advanced editing features of Vim and I've been happy with it for years (more than I'd like to admit).
Is crucial for my personal workflow and one of the only bindings i require.
I use it in conjunction with
`nnoremap - :Explore<cr>` Which opens the best directory navigator in existence (actually dired should be named here)
This changes the game dramatically.
Read about :ls and :b
An LSP client is built into NeoVim itself and support of VSCode extensions not covered by LSP is also available via plugin.
I've seen the rise of Vim popularity from the sidelines, I learned it at the same time as I learned eclipse, continued using vim while learning Sublime Text, IntelliJ, Netbeans and VSCode and I still use Vim.
Here are my thoughts:
If only people had spent half the time they waste on learning enough Vim to impress others learning and setting up VS Code, eclipse, IntelliJ (or tjeir language variant), NetBeans - or even I guess even though I don't like it myself - Visual Studio (the old one).
Please, please, please: at least for those who use modern languages with IDE support, take the time to consider learning the basics of an IDE.
The correct way to refactor moden code isn't to learn to study Vim for years to do it in half the time or with half the shortcuts, but to navigate to the correct line (down, down down), the correct place (2 x ctrl + arrow right) mark the code in question (5 x shift + arrow down to get the majority of it, then shift end to the end of the line) and ctrl + shift + p or something, extra(ct variable), name it and finished.
And this is just the straight forward way for someone knowing nothing but standard text navigation on Linux/Windows: if someone spends a fraction of the time some use on Vim they'll find that there are shortcuts to expand selection to scope built into modern IDEs by default.
The above can be shortened to:
- four times arrow down (we go into the middle of the mess)
- ide specific shortcut (or your chosen shortcut, they can be exported and imported) to expand selection to scope
- ctrl + shift + p to open command palette
- ext (since it is near the top of the list anyway), rename, done
Edit: there exist one good reason to use emacs and vim - they won't be integrated with Github and dumbed down over night, see for example https://news.ycombinator.com/item?id=29461226
Personally I rather learn IntelliJ, Netbeans, eclipse and VS Code somewhat fluently though.
I love the modal editing model, but there’s no denying that vim can be a little clunky when dealing with things that have come along since, like the system clipboard.
Like yes, a lot of people don't give vim a chance, but vim also uses a very specific style of shortcut. If you can cut and paste with your keyboard, you already use IntellJ-style shortcuts (because those are just the default style of hotkey people are used to). The same doesn't go for vim.
(I'm not saying that vi(m) doesn't have its merits, just that the argument can go both ways)
What is the first/main thing you can do when opening a file with vi? Shoot commands at it, not edit text.
Good Luck suffering for some months though, it's worth it in the end :-)
I recommend just leaving hjkl in their default positions, no rebinding. That's what I ended up on and I don't regret it. They aren't in too awkward a position (all accessible by your right index finger). The default bindings are meant to be easily memorable, and you can use them anywhere you can find vim, even if you don't have your custom config.
I tried remapping for Colemak's sake, but I quickly decided against it.
Now I've settled on Colemak-DH with an Extended Layer implemented with Kmonad and I'm a lot happier.
For text navigation (besides the extended layer) I just use the EasyMotion plugin, so no need of remapping. I'm really digging it.