Exit neon sign on brick wall background

Hoe u VIM afsluit en de populairste VIM-snelkoppelingen

If you are reading this article then you are in trouble. You wanted to edit a file using vim editor but got stuck in it. Stop panicking and wait with re-installing the OS and starting all from scratch – in this article I will show you how to exit a vim trap.

google search with request "how to quit vim"
Vim is na het roken het moeilijkste om te stoppen

Sluit de VIM-editor af met toetscombinaties

De Vim-editor is lastig voor beginners, maar als je de juiste toetscombinaties leert, wordt het gebruik van VIM eenvoudig. Hier zijn de populairste toetscombinaties om vim af te sluiten.

Sluit vim af en bewaar wijzigingen

Om vim af te sluiten en de wijzigingen op te slaan, drukt u op Opl om de bewerkingsmodus te verlaten en houd vervolgens ingedrukt Verschuiving en druk op dikke darm key (:). Then enter “w.v” and press Enter. Here “w” stands for write and “q” stands for “quit”. On US keyboards the colon : is dezelfde sleutel als puntkomma ;, located right of the letter “L” key.

:wq

Sluit vim af zonder de wijzigingen op te slaan

To exit vim without saving changes hold down Shift and press the colon key (:). Then enter “q!” and press Enter.

:q!
exit vim without saving changes
sluit vim af en bewaar geen wijzigingen

Sla wijzigingen op zonder bestaande VIM-editor

To save changes without exiting vim hold down Shift and press the colon key (:). Then enter “w” and press Enter.

:w

Vaardig worden in VIM

Nu ik de basisbeginselen van het afsluiten van Vim en het opslaan van wijzigingen heb besproken, gaan we verder met enkele aanvullende handige Vim-snelkoppelingen en -functies om uw vaardigheid te verbeteren.

VIM starten om het bestand te bewerken

Meestal starten ontwikkelaars vim om het bestand te bewerken met behulp van de opdracht:

vim filename

Als het bestand ontbreekt, wordt het gemaakt. U kunt meerdere bestanden opgeven om te bewerken:

vim file1 file2 file3

Om een bestand op een specifieke regel te openen, kunt u [num] toevoegen na het vim-commando. Om bijvoorbeeld een bestand op regel 127 te openen, typt u:

vim filename +127

Once you’ve entered Vim, navigating efficiently is key. Here are some popular shortcuts:

  • De cursor verplaatsen:
    • Gebruik de pijltjestoetsen om in de betreffende richtingen te bewegen (omhoog, omlaag, links, rechts).
    • Alternatively, employ the h, j, k, and l keys for left, down, up, and right movements, respectively.
  • Woordnavigatie:
    • Move the cursor to the beginning of the next word with w.
    • Navigate to the end of the current word using e.
    • Jump to the beginning of the previous word with b.
  • Navigeren door lijnen:
    • Go to the start of the line by pressing 0.
    • Move to the end of the line with $.

Tekst bewerken in VIM

Once you’ve reached the desired location, these shortcuts will aid in text manipulation:

  • Invoegmodus openen:
    • Press i to enter insert mode before the cursor.
    • Use I to start inserting at the beginning of the line.
    • Employ a to append after the cursor.
    • A maakt het mogelijk om aan het einde van de regel toe te voegen.
  • Tekst verwijderen:
    • Delete the character under the cursor with x.
    • Erase the entire line with dd.
    • Cut (delete) the current line and enter insert mode with cc.
  • Kopiëren en plakken:
    • Copy a line with yy.
    • Paste the copied line below the current line using p.
  • Ongedaan maken en opnieuw uitvoeren:
    • Undo the last action with u.
    • Redo with Ctrl + r.

Zoeken in VIM

Efficiënt zoeken is cruciaal. Hier zijn enkele zoekgerelateerde sneltoetsen:

  • Zoeken naar tekst:
    • Initiate a search with /, followed by the desired term.
    • Use n to jump to the next occurrence and N to go to the previous one.
  • Tekst vervangen:
    • Substitute the current word with a new one using :s/old/new/g.

Vim verlaten

Ik heb de basisprincipes in het begin al behandeld, maar hier zijn nog een paar opties:

  • Opslaan en alles afsluiten:
    • To save all changes and quit multiple files simultaneously, use :wa En :qa.
  • Afsluiten zonder op te slaan:
    • If you want to exit Vim without saving any changes made in any of the files, :qa! will do the trick.

Conclusie

Vergeet niet dat het beheersen van Vim tijd en oefening kost. Hoe meer je hem gebruikt, hoe comfortabeler en krachtiger hij wordt. Veel plezier met bewerken!