News for hackers. Stuff that matters.
Re:Vim 8.1 by ssijak on Friday May 18, 2018 @12:19PM (#17102636)
I want to learn Vim and tried several times (with vim modes form Intellij mainly) but failed under pressure to get actual things done. I see great potential and I know I have to sacrifice 1-2 month of productivity to get up to speed but I fail every time.
Re:Vim 8.1 by jmcphers on Friday May 18, 2018 @12:31PM (#17102749)
I've been a heavy Vim user for 20 years, and I hear people say this all the time. Recent converts especially love to write breathless blog posts exalting Vim's editing model as the One True Way, but the truth is that if your editing speed is the bottleneck for your productivity, you must surely be some kind of software engineering deity. There's absolutely no shame in sticking with a model that works for you if you're productive and efficient.
Re:Vim 8.1 by jsat on Friday May 18, 2018 @12:58PM (#17103006)
I think editing friction can take a toll on your total mental energy. I also think that workspace automation can significantly improve the speed at which you complete a task. Vim macros make repetitive tasks on any size file a breeze.
Re:Vim 8.1 by crehn on Friday May 18, 2018 @01:21PM (#17103190)
I concur. It's often easier to reduce the negative effects of friction than it is to increase the positive effects of efficiency.
Re:Vim 8.1 by yodsanklai on Friday May 18, 2018 @12:57PM (#17102996)
Same here, I've been using Vim for a long time. The main reason is that I touch type and I really don't like to use the arrow keys. However, I really wonder if I'm really more productive using Vim rather standard shortcuts plus the trackpad.
Re:Vim 8.1 by jdc0589 on Friday May 18, 2018 @02:40PM (#17103878)
I know im vim'ing wrong, but I just can't stop using arrow keys. Part of it is because I end up navigating around a little bit in insert mode sometimes, and switching between arrow keys for insert mode ans hjkl for other modes seems dumb.

I don't have a problem using hjkl, I guess my problem is NOT needing to move around inside insert mode. Tips?

Re:Vim 8.1 by richchurcher on Friday May 18, 2018 @04:52PM (#17104851)
As furgooswft13 notes, you can use

  Ctrl-O <command>
to issue single normal mode commands from insert mode. Most purists would say switch to normal mode to navigate, and by and large that's true (especially, IMHO, if you bind 'jk' to Esc which is much faster for a touch typist). However, insert mode does let you do this to avoid the arrow keys:

  inoremap <A-h> <Left>
  inoremap <A-l> <Right>
  inoremap <A-k> <Up>
  inoremap <A-j> <Down>
Which some would say enforces 'bad' habits, but I reckon do whatever feels effective to you. If you do find yourself leaning on the direction keys for more than a few repeats, there's probably a faster way though!
Re:Vim 8.1 by furgooswft13 on Friday May 18, 2018 @02:52PM (#17103965)
The vim way is to simply escape out of insert mode, do your movement commands, then go back in.

But you can also use ctrl+o [movement command] while in insert mode to do one-off movements and end up back in insert afterwards.

I honestly don't think however that you betray any vim sacred cows by using the arrow keys, or even the mouse when they are convenient. Such as when in insert mode.

hjkl is just much more convenient in normal mode while your hands are already in the right position.

Re:Vim 8.1 by pull_my_finger on Friday May 18, 2018 @10:09PM (#17106253)
Try HardMode (https://github.com/wikitopian/hardmode) for vim. While it also disables some other stuff, the idea is it will force you to use the more efficient movement options.
Re:Vim 8.1 by maxk42 on Friday May 18, 2018 @03:44PM (#17104388)
iNavigating in insert mode is your problem.ESCo

iThe default mode is called "normal mode" for a reason.ESC:wq

Re:Vim 8.1 by nsomaru on Friday May 18, 2018 @02:59PM (#17104020)
It's not always about typing speed. When typing you are articulating a thought process to the computer, and the faster you can articulate the current thought, the quicker you're on to the next one (although that may involve pondering and not typing) and so on. Vim has really useful "intermediate" things like registers, macros, :args and :argdo which make some menial tasks a little more bearable.

It also speaks to a part of myself that wants to force myself to use the terminal so that I am forced to use an environment which is, in some sense, fully programmable. Also it's nice when you log in to servers (yes, some do still do that; the dying art of vimming over 400ms This is not necessarily a universal viewpoint.

As for plugins, its usually better to learn to do things in pure vim first so that you're not crippled when you get some vanilla goodness 400ms away. Viva vim, viva mosh. Have had some issues with neovim, jedi, jedi-vim python-language server. The prediction looks okay, but it always lags the UI slightly when pulling up predictions which is jarring. This is one part of Pycharm that is missed.

edit: lots "clicks" when you understand verbs, nouns and more complex movements. it's rare to use single character movements once you're proficiently expressing yourself.

Re:Vim 8.1 by vbezhenar on Friday May 18, 2018 @02:44PM (#17103913)
Yep. I think that I know vim well enough, it was a time when I spend months in vim writing C++. vim really shines when you need to do some repetitive tasks. But I've found out that in recent years I don't have those tasks. I'm using Intellij Idea now. If I need to do some repetitive thing, I either rethink the task; use search-replace with regex or just use Idea multiple cursors. Sure, vim might be a little bit better at text editing, but given that I'm spending may be 1% of time on text editing, this optimization just doesn't matter. I tried IdeaVim and decided to stay with traditional hotkeys.

But my vim knowledge helps me every time I need to configure a Linux server, so it wasn't a completely useless experience after all.

Re:Vim 8.1 by computerex on Friday May 18, 2018 @12:37PM (#17102803)
Completely agree. Use whatever you're comfortable with. No one should feel any shame for not using VIM/Emacs. But with that said, I feel like once you are comfortable with these tools, it's a more pleasurable experience.
Re:Vim 8.1 by godelski on Friday May 18, 2018 @02:37PM (#17103840)
They all do pretty much the same, just implemented in different ways. The only reason I tell people that vim is the better choice (when starting from scratch) is that Vi is on every unix system and it is nice to be able to work on any machine. If you don't plan on using unknown machines, do whatever works best for you.
Re:Vim 8.1 by greenhouse_gas on Friday May 18, 2018 @03:06PM (#17104075)
>Vi is on every unix system

Except Debian's install CD. They only have nano.

Re:Vim 8.1 by godelski on Friday May 18, 2018 @05:02PM (#17104933)
Are you sure? I just looked through an old Debian 8 iso that I have and it had vim in it.
Re:Vim 8.1 by andrewmcwatters on Friday May 18, 2018 @12:42PM (#17102855)
Thanks for chipping in with this. As an Atom undesirable, I've found myself wanting to use Vim now and again over the years, but I know that my productivity shortcomings revolve mostly around motivation, drive and cognitive ability, not typing speed or editing slickness. I think with a handful of keyboard shortcuts I can mostly keep productive speed, although I'm sure I'd never outpace a Vim user.
Re:Vim 8.1 by jdc0589 on Friday May 18, 2018 @02:31PM (#17103788)
This. I switched to Vim full time as part of starting a new job and picking up a new stack/language, because I was so frustrated with how useless/frustrating Ruby IDE and editor environments all seemed.

The only time my progress is hindered (im still not amazing in Vim) is during debugging, which is why I'm pretty excited about this update.

Re:Vim 8.1 by ssijak on Friday May 18, 2018 @12:41PM (#17102848)
I often have something to do on some remote linux server and I want to kill my self every time I open some large file in Nano trying to edit something.

Also, when programming, my writing speed is not my bottleneck, but I hate using my touchpad to move the cursor and want to learn vim for both editing prownes and server file editing too.

Re:Vim 8.1 by danielbarla on Friday May 18, 2018 @01:16PM (#17103153)
I think you can successfully migrate to vim modes by using less than optimal vim habits initially. I don't think anyone is going to go through the entire action list and instinctively remember all of them, and be able to use them at a moments notice.

As an example, my transition was something like this: I'd use a vim plugin, and use say 5- 7 basic actions + movements like `cw`, `c$` `i`, and keep it limited to that for a while. If you're frustrated, simple insert mode (`i`) is all you need to get back to your comfort zone. Pretty soon, you get those ingrained, and then start looking for other tricks to learn. A few years later, it's second nature and you're probably slightly more productive. Bottom line is that it shouldn't take you 2 months to break even, hopefully.

Re:Vim 8.1 by eckza on Friday May 18, 2018 @01:23PM (#17103201)
This is how I've learned! I'm about 8 years in with vim, but I'm no vim-journeyman; I just learned enough to get started. Movement, find-and-replace, splits. The basics.

And every time I wonder if there's a better way to do whatever I'm doing, I look it up, and - lo and behold - I learn some cool new feature that I can organically introduce into my workflow.

Learning vim in this way has been immensely satisfying. I look at time spent in vim as an investment in my career as a software developer. For as long as I'm in this industry, I'm going to need to edit text. vim can do just about anything and everything; will run on any architecture, past, present, or (it's safe to assume) future; and has allowed me to reduce the amount of time that I spend doing repetitive editing tasks.

Re:Vim 8.1 by strkek on Friday May 18, 2018 @01:50PM (#17103442)
> If you're frustrated, simple insert mode (`i`) is all you need to get back to your comfort zone.

Also, something I wish I knew back when I was learning is `:set nonumber` to turn off the gutter and be able to copy things with the mouse (`:set number` turns it back on).

If I had known this, my experience wouldn't have been as bad as it was until I learned to use the registers.

Re:Vim 8.1 by Symmetry on Friday May 18, 2018 @02:04PM (#17103573)
If I had as much extra time as I ever wanted one of the projects I'd work on would be a vim-style modal editor where ctrl-X in insert mode usually corresponded to X in normal mode and where CUA conventions are followed when practical. And where you do move-command rather than command-move and you have both an emacs yank-ring and a vim jump-ring.
Re:Vim 8.1 by godelski on Friday May 18, 2018 @02:39PM (#17103865)
Path I took is to learn the basic movements. Then just put a sticky note with new commands each week. Whatever I didn't use I didn't commit to memory. But knowing commands exists helps.
Re:Vim 8.1 by nsomaru on Friday May 18, 2018 @03:03PM (#17104054)
looking to do this at an intermediate level. any commands you can recommend?
Re:Vim 8.1 by godelski on Friday May 18, 2018 @04:16PM (#17104619)
By far I think the most over looked commands are the <C-x> commands while in insert mode. They do the auto complete. They all follow this pattern <C-x>letter.

Try out: l (line), n/p (next/previous instance of word), f (file)

Note that you can hammer these.

The next important thing I suggest is using buffers, splits, and marks.

Re:Vim 8.1 by maxk42 on Friday May 18, 2018 @03:53PM (#17104467)
Make sure you know your buffers and marks.

Also make sure you understand the difference between u/CTRL-R and g+/g-.

Macros (q) are also useful. Also, v, V, CTRL-V for selections. And gv to re-select previous selected area and gn / gN to operate on the next/previous match.

Re:Vim 8.1 by lozenge on Friday May 18, 2018 @03:41PM (#17104362)
Star and hash - find previous and next match for word under cursor

n and N - find previous and next match for current search.

Re:Vim 8.1 by kenneth on Friday May 18, 2018 @12:33PM (#17102771)
Use real vim, not emulators. Emulators all suck, and won't teach you the right habits.

Vim is also extremely powerful when customized to your needs. Build your own setup over time. Start with vanilla vim and add to it over time. If anything annoys you and requires too much manual repetition, it can probably be automated and streamlined.

Force yourself to use Vim for everything, and soon enough it'll be second nature.

Also — consider Neovim. It's real vim, but better.

Re:Vim 8.1 by extr on Friday May 18, 2018 @01:37PM (#17103337)
I actually disagree. I found what finally led to me using VIM was enabling VIM keybindings in RStudio. It's an emulated VIM setup, so not every command is supported, but it does have the advantage that at any point Insert mode works pretty much exactly like a non-vim setup. After a few months of this sort of semi-usage, I started to feel confident enough to use regular VIM, and started looking into more advanced command usage. The biggest thing was still, the ability to drop into Insert mode and have things like selection, copy/paste, backspace behavior, all work like they would in a normal text editor. If I got frustrated and needed to "just get something done", I didn't have to drop into notepad or whatever to do that. Rather than start off with no vimrc, I think its a lot more helpful to start with a vimrc that disables a bunch of functionality or makes it work "normally", which you can then re-enable as you see the need. For example, at first I shortcutted all registers to the system register.
Re:Vim 8.1 by supermdguy on Friday May 18, 2018 @12:50PM (#17102919)
What, specifically, is the problem with emulators that make them not teach the right habits? I get that emulators are likely more bloated and have less features than real vim/neovim. But, to me, that's not a dealbreaker, especially since it can be really convenient to use an emulator in an IDE.
Re:Vim 8.1 by notheguyouthink on Friday May 18, 2018 @12:54PM (#17102958)
As an aside, there are GUIs coming out for Neovim that give you features of IDEs with 100% real backing of Vim/Neovim. Ie, it's actually Neovim, but the GUI is just a frontend with IDE bells and whistles.

Most are pretty young I believe, so maybe not ready for you. I'm sure it's coming though :)

Re:Vim 8.1 by xur17 on Friday May 18, 2018 @01:39PM (#17103350)
I would agree with this. Emulators typically are missing a few features, so moving from emulator -> vim should work okay. On the other hand, I've never had success going from vim -> emulator. It's always missing a few key features in my muscle memory that completely destroy my productivity.
Re:Vim 8.1 by maxk42 on Friday May 18, 2018 @03:55PM (#17104484)
vim's feature-set is not just large -- it's vast. After 11+ years using it, I doubt I'm familiar with 1%.

There is no emulator that has that completeness. Most scarcely implement the beginner commands.

Re:Vim 8.1 by neurotrace on Friday May 18, 2018 @01:58PM (#17103520)
Nah. Vim bindings in VS Code are the sweet spot for me. Some of the Vim emulation isn't perfect but having something like 99% of Vim is plenty plus I get my preferred layout, debugging tools, etc.
Re:Vim 8.1 by moistoreos on Friday May 18, 2018 @02:32PM (#17103802)
I use Vim bindings for VS Code with the Angular work I'm doing at my job. I can vouch that they're the best emulated bindings outside of any JetBrains app that I've touched.
Re:Vim 8.1 by jdc0589 on Friday May 18, 2018 @02:41PM (#17103886)
does jetbrains do ANYTHING poorly? it seems like everything they touch is gold.
Re:Vim 8.1 by nobleach on Friday May 18, 2018 @05:46PM (#17105213)
Atom's vim-mode-plus is superb! I've actually started to like it more than "real vim". Atom itself is a work-in-progress, but I'm extremely happy with its vim emulation. The only thing missing is a macro system.
Re:Vim 8.1 by inyorgroove on Friday May 18, 2018 @12:25PM (#17102690)
There is this game that was posted to HN earlier this week [1]. There is also `vimtutor` a text file that walks you through a tutorial in vim, I believe this ships by default with vim [2].

--

1: https://www.ostechnix.com/pacvim-a-cli-game-to-learn-vim-com...

2: https://superuser.com/questions/246487/how-to-use-vimtutor

Re:Vim 8.1 by tomcooks on Friday May 18, 2018 @12:40PM (#17102833)
Vimtutor done once a day for a week beats anything else

Added bonus if you force yourself to use a handful of commands for the whole 7 days (I suggest focusing on dd, yyp, xp, cw and obviously hkjl for movement)

Re:Vim 8.1 by smhenderson on Friday May 18, 2018 @12:38PM (#17102818)
vimtutor is what got me over the initial hump. I dabbled with Vim for a year or so before I found it. Within a couple of weeks after using it for an hour or so a day I felt very comfortable and have used Vim, environment permitting, as my primary editor ever since.

Thanks Bram!

Re:Vim 8.1 by computerex on Friday May 18, 2018 @12:30PM (#17102736)
You don't have to use VIM as your daily driver, you can use it on your personal projects. I was in the same boat as you. But now that I am comfortable with VIM, I feel like learning it has been one of the most rewarding and fruitful investments I have made in myself. I use it for JavaScript, Python, C#, golang, and more.
Re:Vim 8.1 by sudeepto_dutta on Friday May 18, 2018 @12:45PM (#17102877)
I think learning to touch type is an unofficial prerequisite for learning vim. If you "peck & hunt" type and use vim on top of that, I think you'll get frustrated pretty quickly.
Re:Vim 8.1 by samatman on Friday May 18, 2018 @01:13PM (#17103129)
The thing that (finally) worked for me was to pick a language that I wasn't using at work (C in this case), and do a project in it using exclusively vim.

Once I learned the basics, I only use vim itself for commits and small scripts, but this made using vim /modes/ in spacemacs and VSCode practical.

Without the basic vocabulary it just feels like turning on 'cripple mode' while you're trying to get work done.

I'm still not an expert; I heavily reuse the same ~15 commands. I've found learning that vocabulary to be very much worthwhile.

Re:Vim 8.1 by throwaway413 on Friday May 18, 2018 @12:32PM (#17102758)
Find a good cheatsheet that you're able to browse through quickly. Uninstall every GUI editor you have on your machine.

It took me ~ a month before I was fully getting the hang of it. Now I'm about a year in and not only has my familiarity with my keyboard greatly improved, but I am finally reaping the benefits of speed and portability (gotta love having an identical editor experience on any machine you SSH into).

Re:Vim 8.1 by akavel on Friday May 18, 2018 @12:57PM (#17102997)
I was in a similar situation, tried a few times but always bounced off. In the end, a job where I had to use vim (because connection to our remote dev machines was abysmally slow) forced me to learn it. I think that even then for some time I used to say that any love for vim is just a symptom of the Stockholm Syndrome. Then at some point I discovered the "quicklist" feature, which with :cex system('...') became my conversion point. Now I'm also fully in the "Stockholm Syndrome" victims† camp, and do love my oppressor, for a few years already... Only sometimes for faster browsing/reading with a mouse I switch to some "classical" IDE with a files pane and quick navigation, like IntelliJ or VSCode.

† "vi-ctims" pun not intended; but then...

Re:Vim 8.1 by aranelsurion on Saturday May 19, 2018 @07:53AM (#17107497)
I don't think you have to sacrifice any meaningful amount of productivity to learn Vim. Contrary to popular opinion, I think vim has a pretty smooth learning curve to begin editing with it.

It might take a bit more effort to learn than, say, Sublime Text or Atom, yet after playing with "vimtutor" and reading a blog-post or two, you can learn how to open a couple of files and display them in splits, how to do modal editing, search, replace, copy/paste[1], undo/redo, save and close in a vim buffer. It's basically everything you will need to start using vim as your primary editor and it can be learned in a couple of hours.

After that, you can always learn deeper aspects of vim later and customize it in a leisurely pace in weeks to come.

Re:Vim 8.1 by WorldMaker on Friday May 18, 2018 @12:56PM (#17102988)
Have you tried to switch for a while to a laptop with no mouse, a terrible trackpad that hardly ever works, and painful to use and/or broken Home/End/Page Up/Page Down and Arrow keys?

It's partly a joke, but it is the "rip off the bandaid" style way to learn Vim. On a system like that you pretty much either learn Vim or perish. I had a Dell laptop like that in grad school which is where I probably used Vim the most consistently I'll ever use it in my life (and used all sorts of other fun key-focused things like xmonad and Vimperator then as well).

Re:Vim 8.1 by smhenderson on Friday May 18, 2018 @02:19PM (#17103685)
When I got serious about learning Vim and was doing vimtutor I rigged up a piece of cardboard over the numeric keypad, the PgUp, etc keys and the arrow keys so when I tried to use them I couldn't.

It took my brain a while to stop reaching for them but eventually it worked. To this day I naturally shy away from them although I've overcome that somewhat when it comes to using the numeric keypad.

It's kinda of similar to the Right Menu key in Windows. I hit Shift-F10 for so long I never got used to this new key and used it.

Re:Vim 8.1 by Veedrac on Saturday May 19, 2018 @11:00PM (#17110939)
If you just want to learn Vim because you think it's some magically fast editor, don't. It's not particularly fast at expressing actions, and modal editing is mostly useful if you have a particular dislike of chording.

I suspect most Vim users feel comparatively fast because of all the time they spent learning keybindings, not because of the editor. So just do that: figure out how to do editing actions faster in your current editor. I can beat a significant fraction of VimGolf scores with Sublime Text.

Re:Vim 8.1 by ben174 on Friday May 18, 2018 @12:54PM (#17102959)
You're absolutely right that you have to sacrifice some productivity to get it done. I was lucky enough to have been working a graveyard NOC job for a few months and had nothing but time (when fires weren't burning). This gave me the opportunity to just immerse myself in VIM. It's easily been one of the best things I've ever done for my productivity.
Re:Vim 8.1 by renox on Friday May 18, 2018 @06:35PM (#17105451)
I'm currently trying to switch from Eclipse to vim: to ease the transition I'm using gvim. One difficulty with vim is that you have to configure it because by default it's pretty dumb..
Re:Vim 8.1 by taf2 on Friday May 18, 2018 @12:20PM (#17102641)
Command line - and just keep trying... after a few years it’ll stick
Re:Vim 8.1 by mdaniel on Friday May 18, 2018 @12:33PM (#17102770)
with vim modes form Intellij mainly

Definitely don't do that. A well-written IDE should never make one express movement in terms of text because source code is only serialized as text, but the unit of movement should always be symbols. I love vim dearly, and it is an outstanding text editor, but no one should be programming in it when a more intelligent editor exists for the language.

I have seen people trying to fight with the vim plugin in IJ and it has yet to end well

Re:Vim 8.1 by SeoxyS on Friday May 18, 2018 @12:43PM (#17102866)
I'd love to see you swap the implementation two methods efficiently without vim. For me, just a few keystrokes: dim]mvimp2[mP and about 3 seconds. For you: a bunch of clicking and selecting, I imagine.

This is just one example of many I could come up with. Code is text, and vim can easily be made to understand that text well.

Re:Vim 8.1 by ivanche on Friday May 18, 2018 @12:54PM (#17102962)
Please try harder. Ctrl+Shift+Up (or Ctrl+Shift+Down), about 0.3 seconds.
Re:Vim 8.1 by maxk42 on Friday May 18, 2018 @03:41PM (#17104364)
It's okay: We all did.