Exit neon sign on brick wall background

Kuidas väljuda VIM-ist ja kõige populaarsematest VIM-i otseteedest

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 on suitsetamise järel teine kõige raskem asi, millest loobuda

VIM redaktorist väljumine klahvikombinatsioonide abil

Vim redaktor on algajatele keeruline, kuid kui õpite õigeid klahvikombinatsioone, siis VIM-i kasutamine muutub lihtsaks. Siin on kõige populaarsemad klahvikombinatsioonid vim-ist väljumiseks.

Vim-ist väljumine muudatuste salvestamisega

Vimist väljumiseks ja muudatuste salvestamiseks vajutage Esc klahvi, et välja minna redigeerimisrežiimist, seejärel hoidke all Shift ja vajutage koolon key (:). Then enter “wq” and press Enter. Here “w” stands for write and “q” stands for “quit”. On US keyboards the colon : sama klahv kui semikoolon ;, located right of the letter “L” key.

:wq

Väljuge vimist ilma muudatusi salvestamata

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
väljuge vimist, salvestamata muudatusi

Salvesta muudatused, ilma et VIM-i redaktorist väljutaks

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

:w

VIMi oskuslikuks saamine

Nüüd, kui olen katnud Vimi sulgemise ja muudatuste salvestamise põhialused, liikume edasi mõne täiendava kasuliku Vimi otsetee ja funktsiooni juurde, et suurendada teie oskusi.

VIMi käivitamine faili redigeerimiseks

Tavaliselt käivitavad arendajad vim'i faili redigeerimiseks käsuga:

vim filename

Kui faili pole, siis see luuakse. Saate redigeerida mitut faili:

vim file1 file2 file3

Konkreetse rea avamiseks failis saate vim'i käsule lisada +[num]. Näiteks, et avada fail real 127, sisestage:

vim filename +127

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

  • Kursori liigutamine:
    • Kasutage nooleklahve, et liikuda vastavates suundades (üles, alla, vasakule, paremale).
    • Alternatively, employ the h, j, k, and l keys for left, down, up, and right movements, respectively.
  • Sõna navigeerimine:
    • 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.
  • Rea navigeerimine:
    • Go to the start of the line by pressing 0.
    • Move to the end of the line with $.

Teksti redigeerimine VIM-is

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

  • Sisestusrežiimi sisenemine:
    • 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 lubab rea lõppu lisama.
  • Teksti kustutamine:
    • 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.
  • Kopeeri ja Kleepeka:
    • Copy a line with yy.
    • Paste the copied line below the current line using p.
  • Tagasi ja Korda:
    • Undo the last action with u.
    • Redo with Ctrl + r.

Otsimine VIM-is

Tõhus otsimine on ülioluline. Siin on mõned otsinguga seotud otseteed:

  • Teksti otsimine:
    • 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.
  • Teksti asendamine:
    • Substitute the current word with a new one using :s/old/new/g.

Vimist väljumine

Olen juba alguses põhialused katnud, kuid siin on veel mõned valikud:

  • Salvesta ja välju kõigist:
    • To save all changes and quit multiple files simultaneously, use :wa ja :qa.
  • Väljumine salvestamata:
    • If you want to exit Vim without saving any changes made in any of the files, :qa! will do the trick.

Järeldus

Pea, Vim'i valdamine võtab aega ja harjutamist. Mida rohkem sa seda kasutad, seda mugavamaks ja võimsamaks see muutub. Head redigeerimist!