On learning vi/vim
Posted by jpluimers on 2022/01/13
I saved below thread (if you cannot read German: try Google Translate on it [Archive.is]).
The part that – translated – strikes me most is this:
A mini-challenge where I want to spent 15 minutes per day on: when I need some functionality, instead of hacking around, research how it really is supposed to be done and internalise that way.
This totally aligns with me “learn new things every day” mantra.
Also some interesting vi
/vim
resources and approaches are mentioned:
- Ditch those plugins
- A 1.5 hour talk about
vi
/vim
: vim + tmux – OMG!Code – YouTube. - Use mnemonics to remember the various vim commands (like “
ciw
” -> “change inner word”) - Use
vimtutor
:- [Wayback/Archive.is] vimtutor/vimtutor at master · TheNaoX/vimtutor: source code
- [Wayback/Archive.is] vim – How to use vimtutor? – Super User
Yes,
vimtutor
is literally the name of a program that runs you through a tutorial forvim
. If installed on a Unix environment, that command should be sufficient. On windows, there’s an entry in the - [Wayback/Archive.is] A Day with Vim Tutor (vimtutor). vimtutor is a very basic, clean and… | by Minh-Phuc Tran | Level Up Coding
vimtutor
is a very basic, clean, and cool application that teaches you how to use Vim. It’s the best place to get started usingvim
. Spending about 1 hour withvimtutor
, you can pretty much get all major features ofvim
.However, 1 hour is somewhat too much for guys who aren’t that interested in
vim
. Therefore, I wrote this 3-min-read article summarizing what and howvimtutor
can teach you, then you can decide to jump into it later.…
If you are better at reading tables or lists for commands, I can recommend [Wayback] Basic vi Commands (Computer Science Department, Colorado State University).
One of the hardest things for me to remember somehow is the search/replace syntax, though it is very similar to that of sed
. Useful examples of most permutations are at [Wayback] Vi For Smarties – Lesson Eight under “Advanced Search and Replace”:
- Use :s/foo/bar/ to replace the first occurrence of the word foo on the current line with the word bar.
- Use :s/foo/bar/g to replace all occurrences of the word foo on the current line with the word bar.
- Use :%s/foo/bar/g to replace all occurrences of the word foo in the current file with the word bar. Leaving off the g at the end only replaces the first occurrence of foo on each line of the current file.
- Use :%s/foo//g to delete all occurrences of the word foo in the current file. Leaving off the percent sign (%), of course, only does this for the current line.
- Use :%s/foo/bar/gc to have Vi query you before each attempt to replace the word foo with the word bar.
It is part of a series of tutorials starting at [Wayback] Vi For Smarties – Lesson One, and after the last lesson directs to the in-depth – as prose written – tutorial series [Archive.is] Wayback: The Vi/Ex Editor (which, despite marked by “[ Editor’s Note: . This tutorial series is a “work in progress” and will evolve over time. We’ll announce each new addition and expand this table of contents.]” got ditched shortly after January 2006)
https://web.archive.org/web/20160108053134/http://www.networkcomputin…
.
Note that like sed
, you can use a different search/replace character than /
: [Wayback] vim – / in vi Search and replace? – Stack Overflow
- Escape the
/
with\
like this:\/
.- Use different search character than
/
, for instance.,
or#
.
Back to the twitter thread
[Archive.is] Das königliche Wir on Twitter: “Ich lerne jetzt vi(m). Klingt beknackt, oder? Aber ich hab überlegt: ich möchte effizienter werden, meinen Kram stressfreier bewältigen. Und ich finde, es bietet sich an da an Baustellen anzusetzen, die täglich relevant sind. Und vi(m) nutze ich in der Tat täglich. 1/”
Ich lerne jetzt vi(m).
Klingt beknackt, oder? Aber ich hab überlegt: ich möchte effizienter werden, meinen Kram stressfreier bewältigen. Und ich finde, es bietet sich an da an Baustellen anzusetzen, die täglich relevant sind. Und vi(m) nutze ich in der Tat täglich.
Aber auch wenn ich ihn nutze und über den »Hilfe, wie komm ich aus dem Editor wieder raus?!«-Witz nur sehr müde die Augen rolle gehe ich davon aus, dass ich nicht mal einen Bruchteil der Möglichkeiten ausschöpfe, die er bietet (1. Release 1976, älter als ich!). Das ist spannend.
Das ist jetzt meine Mini-Challenge, auf die ich jeden Tag eine Viertelstunde verwenden will: wenn ich eine Funktion brauche mich nicht mehr drum herum zu hacken, sondern recherchieren wie es richtig geht und das dann gefälligst auch verinnerlichen. Mal sehen, ob das so klappt
In dem Zuge will ich auch wieder verstärkt (neo)mutt in Verbindung mit vim nutzen – das wäre ein wunderbares tägliches Training 😎 Mails schreiben muss man irgendwie immer.
neomutt bietet leider auch einen Eimer voll Funktionen, die ich noch nicht ordentlich nutze. Gnah.
An euren Replies erkenne ich, dass das mit dem »sich die Kürzel merken« echt heikel zu sein scheint 🤔 Wie handhabt ihr das im Alltag? Einfach ein paar Basics wie :u und CTRL+r und gut ist? Ich bin neugierig. Oder nutzt ihr alle nano? (Ich glaub, dann muss ich entfolgen) 😂
Nur als kleinen Zwischenstand: nach dem Lesen eurer Antworten schließe ich, dass ich mich mit meinem Kenntnisstand nicht verstecken muss 😂 Da hat mir der virtuelle Schulterblick schon weiter geholfen.
vi(m), weil ich Admin bin und dieses Tool auf jedem System und ohne X-Geraffels üblicherweise vorfinde (wenn auch bei neueren Installationen dieser absurde „visual mode“ der Default ist 😳). Auch unter (Open)Solaris, IRIX, was weiß ich.
Antworten:
Patrick Ben Koetter (@patrickbkoetter)
Ich habe diverse Plugins ausprobiert und lande immer wieder bei “normal“, weil ich einfach nicht die Disziplin aufbringe das Zeug richtig zu üben.
Marcel Weinberg (@winem_)
Denke so geht es vielen, die eben teilweise auch schon viele Jahre in der IT sind. Ist dir vimtutor bekannt? Den regelmäßig durchzutanzen hilft auch etwas, auch wenn man einiges immer mal vergisst oder einfach nicht nutzt.
Kristian Köhntopp (@isotopp)
vi movement Kommandos haben System. Erkenne und lerne das System. hjkl + prefix+hjkl, Marken, prefix+jump to mark und so weiter.
Und bleibe von den verblödeten Plugins weg. Die braucht kein Mensch und machen vim nur langsam im Start und kompliziert.
Boris (@k3rvyn)
Was mich so richtig weiter gebracht hat, war dieser Talk:
https://www.youtube.com/watch?v=5r6yzFEXajQwinfreak (@winfreak)
Ich bilde mir kleine Merkphrasen für movements…
Aus „ciw“ wird „change inner word“, z.B.
Das kann ich mir deutlich besser merken.
–jeroen
Leave a Reply