Vim Modes Transition Diagram
rawgit.com
rawgit.com
The approach to vi(m) that really worked for me is to regard the different modes (especially insert mode) as commands rather than "modes". Entering text is a single command, usually starting with 'i' or 'a', terminated with <esc>. For each command you learn, get in the habbit to initiate and to terminate it, just like in primary school you learned the habbit of finishing your sentences with a punctuation mark. Then you don't "get stuck" in different modes anymore.
Documentation is a technology, and all technology serves a goal-oriented process.[1]
What you're looking for is a Quick Start Guide. These exist. Vimtutor would be an excellent example.
This ... is a map of the landscape. It doesn't tell you where to go, or what the highlights are. But if you happen to be in one part of the landscape, or want to know what's in some remote part, this shows you both what's where and how to get there. And links to a detailed description for closer inspection.
And in that process and to that goal, it really is quite good.
________________________________
Notes:
1. That is a bald statement proposed as but not presumed true. Change my mind!
Or you'd want to show it to a beginner as a phased reveal. That might actually make an interesting evolution of the diagram, which I'm visualising in my mind as either a set of concentric circles or regions of expanding complexity, or a set of 3D-relief "peaks" emerging from a "feature sea", where the basic elements (say, the Insert mode entry points, h/j/k/l keyboard movements, and, um, how to quit, might be covered.
With more advanced functionality exposed as deeper / more remote regions of the map.
This is quite excelently done, thank you darcyparker!
Note that this doesn't include all features. Digraphs (Ctrl-K from Insert mode) are missing, e.g.
It doesn't have alt<char> to enter normal commands from insert mode (double the number of lines).
It doesn't have (Vim 8) terminal mode.
[1]: https://rawgit.com/ [2]: https://gist.githubusercontent.com/darcyparker/1886716/raw/c...
I use normal select when:
- I want to apply a regex to a specific area, e.g. a single function (vjjjjj:s/my_function/my_new_function/g<enter>)
- I want to cut some text and I don't want to count how many words out it is (vwwwwx)
I use block select when:
- I want to delete a section of fixed width formatted text (Vjjjlllx). Useful for manipulating logs with a fixed width prefix.
- I want to append text to the start of a line. (VjjjjjjI# <esc>). Useful for commenting out lines.
- select from block requires Ctrl-G and then start typing, but c or s is more direct
- select character uses gh, but c is more direct
- select line uses gH, but C is more direct
In what circumstances would Select mode be more direct than to go from Visual to Insert, or from Normal to Insert?
I would definitely consider it a misfeature, given how it complicates things, muddying modes when invoked, and when a simple c or s from any visual mode has roughly the same effect.
The big question for me is whether anyone knew of virtual select mode, enabled by `gR`.
It's like select mode except that it replaces screen state instead of characters, so pressing `<Tab>` will replace `tabstop` characters instead of just one.
I just wish I had a big enough screen to read this all without zooming out
<ESC><ESC>:q!
There you go.Thanks for posting this; bookmarked.
(*) apart from :q!
I think almost all modern products focus exclusively on growth: acquiring new users. That means that it's OK to break existing behaviors if it makes something easier for a newcomer. Vim does not have this attitude, so a newcomer has a steep learning curve, but an old-timer doesn't have to worry about his platform changing from under him.
For some of us, it isn't that hard to learn, and gives us an entirely new way to think and interact with a computer.
I think there is a powerful lesson for user-facing application developers here. Sometimes you're better off thinking of power users and enticing newcomers to put in the effort. Blender seems to follow that approach as well.
Recently I installed vim plugin for vscode and spent a little time digging deeper into vim and practiced until it got into muscle memory.
One little shortcut that I've noticed even some experienced users aren't aware of is :x to save and exit. It is equivalent to :wq
Edit: vscode also has some proprietary debuggers.
https://github.com/VSCodium/vscodium/blob/master/DOCS.md#pro...
First you learn how to enter text and move around a bit.
Next you learn some more advanced features to move and edit more effectively.
Then you learn that vim actually functions at different levels, characters, words, lines, and paragraphs, and learn ways to work on those items specifically.
You learn that complex macros are built in and can easily be recorded and applied as needed.
Finally (maybe?) you learn that all this combines into its own little programming language made to work on documents, and you can use this to quickly do amazing things.
But here's the thing, even if you stop only partway into it, you've still learned how to edit files in an editor that will be on every Unix machine you encounter, even if that version may not have all the bells and whistles.
It's an extremely powerful and ubiquitous tool. Even if you don't use it as a primary editor, there are benefits to knowing how to use it with a moderate proficiency, so many people do.
And this is instant cred when one is new to a project, and have to log in and fix something on a random serber out in the cloud.
Vi is something of a litmus test.
The same people using vim swear by using CLI only tools and by the time they've found the command they want to edit and run in their bash history, I've hit Ctrl+Shift+G, entered my commit message and hit Ctrl+Enter to push. In the time it takes them to switch modes, I've already run the command I wanted to run since many commands are a single hot key and others are on an MRU list.
For editing stuff on a live server, in those rare events when nano isn't available I've always gotten by knowing the bare minimum - how to insert text, write and quit. But I haven't encountered a server lacking nano in years.
Maybe I haven't seen the fastest vim user though. So I looked just now and found [0]. I chose to watch [1] and ~1:24 you can see a demonstration of the guy typing out a command, "Switch" to switch a code symbol from the "true" to "false"... I thought that was hilarious because he typed 6 characters (7 if you include ENTER) in order to save himself from typing 5 characters and I just couldn't watch anymore after that so I left, wondering how many man hours have been spent bike shedding in vim.
That said - I didn't have the patience to find anything showing somebody doing something in vim that can't be done faster in VS Code, Sublime, etc. - so maybe a vim fan can point me in the right direction?
[0] https://old.reddit.com/r/vim/comments/3k1b7n/fastest_vim_vid...
They are showing how it works, so as an example highlight/select manually a bit of text then manually run it to show it swapping the value. There's a few things to consider here:
- They are typing it out because the are demoing it and that's the name it's defined as in the code. Normally someone adding it would also add a key combo activation for it if they planned on using it often in that manner, and make it work on the word element under the cursor.
- Even if a key combo wasn't added, they could also use this while selecting a larger chunk of text to switch all occurrences of one thing the the opposite.
- The real usefulness for this is more likely in the case of some well formatted JSON, where you could start a macros, search for the next top level object, they search for a specific key in that object you know is the next occurr nice of a search term, then go to nth item, then run switch (maybe even typing it out). Then stop the macro. You can then rerun that macro with 1 (or at most a few) key presses the number of times you want, to perform those complex actions a defined number of times.
As needed, vim is like an extensible interactive sed command. That doesn't mean I never use vim, but being able to do something similar to the text manipulations I do with sed while withing the file to confirm it worked right and undo if needed is sometimes useful.
Could the JSON example above have been done with a dedicated tool? Sure. But it gets more complex for dedicated tools if the JSON is embedded in something else, and the important idea is not JSON editing, but that vim gives you a toolset that works just as well for XML or source or plain text, as the primitives it works with generally map well to how we use text.
If you favor one corner, the opposit side will degrade.
VIM is full on functionality/ergonomics with absolutely zero intruitivness.
It's a very steep learning curve.
Once you reach that point in the curve where stuff are easier/faster to do in vim then something else, you can never go back.
ergo the user base.
This is loke starting a maze at the end, amd precisely the sort of backward thinking that affords some excellent solutions.
This isn't to scoff at great UX and design work; merely to point out that the wildly offbeat can surprise in a good way.
Over the subsequent three and a half decades, I've had an editor on virtually every computer system worthy of the name which Just Does What I Want It To. It's there for everything from one-liners to book-length files to editing multi-GB datasets or Web scrapings.
And I'm still learning features and concepts, though now around vim rather than the original BSD vi.
And no, vi isn't the only editor I've used with proficiency: DOS EDIT, EDLIN, KEDIT, WordPerfect 4.11, VMS EDT, VMS EVE, TSO/ISPF, Emacs, pico, nano, and more.
I quite honestly wish I could get back into emacs, but vim has a stronger pull and solves virtually all my problems. org-mode does have strong appeal, however.
Yes, it takes a bit to get used to its controls, but I'm not sure there's a super easy way to teach modal editing to newcomers. On the other hand it's a really reliable and efficient tool that just doesn't try weird stuff. If you have a 1000 line configuration file you can blindly upgrade to the next version and trust everything is still working exactly the same. Considering how many apps do the opposite and add random changes all the time to A/B test everything, this is very valuable.
And while I wouldn't call it perfect, I think editing text is really, really intuitive and fast once you're used to it, to a degree using a mouse in other editors feels slow.
The reason vim doesn't use cursor keys for movement is not because of some secret insight but because the keyboard it was invented on didn't have them.
Similarly the concept of modes was just due to the time period. Commands were the normal way to operate editors. For many people, not many years had gone by since the editing was done on a teletype. Interactive editing was barely even a thing.
I recommend the `micro` editor.
I had tried to go all in on vim a few times but the learning curve always made me feel less productive than working in VS Code.
After adding the vim extension in VS code and gradually learning new commands, it stuck.
Very happy to have learned vim but I agree that the learning curve is pretty steep usually. It was frustrating enough that I published an interactive vim course that helps people get over the hurdle.
Take that file to your local print shop, as suggested in another comment.
q again -> finish recording
@ <somethinge else> -> replay recording of buffer <something else>
q is used to start a recording