Exit neon sign on brick wall background

Kaip išeiti iš VIM ir populiariausių VIM sparčiųjų klavišų

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 yra antras sunkiausias dalykas mesti po rūkymo

Išeikite iš VIM redaktoriaus naudodami klavišų derinius

Vim redaktorius yra sudėtingas pradedantiesiems, tačiau išmokus tinkamų klavišų kombinacijų naudojant VIM tampa lengva. Čia pateikiami populiariausi klavišų deriniai, norint išeiti iš vim.

Išeikite iš Vim išsaugodami pakeitimus

Norėdami išeiti iš vim ir išsaugoti pakeitimus, paspauskite Esc klavišą, kad išeitumėte iš redagavimo režimo, tada laikykite nuspaudę Shift ir paspauskite dvitaškis key (:). Then enter “wq” and press Enter. Here “w” stands for write and “q” stands for “quit”. On US keyboards the colon : yra tas pats raktas kaip kabliataškis ;, located right of the letter “L” key.

:wq

Išeikite iš vim neišsaugoję pakeitimų

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
išeiti iš vim neišsaugoti jokių pakeitimų

Išsaugokite pakeitimus be esamos VIM redaktoriaus

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

:w

Įgyti VIM įgūdžių

Dabar, kai aptariau išėjimo iš „Vim“ ir pakeitimų išsaugojimo pagrindus, pereikime prie papildomų naudingų „Vim“ nuorodų ir funkcijų, kad pagerintumėte savo įgūdžius.

VIM paleidimas failo redagavimui

Paprastai kūrėjai paleidžia vim norėdami redaguoti failą naudodami komandą:

vim filename

Jei failo trūksta, jis bus sukurtas. Galite nurodyti kelis failus, kuriuos norite redaguoti:

vim file1 file2 file3

Norėdami atidaryti failą konkrečioje eilutėje, po komandos vim galite pridėti [num]. Pavyzdžiui, norėdami atidaryti failą 127 eilutėje, įveskite:

vim filename +127

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

  • Žymeklio perkėlimas:
    • Rodyklių klavišais judėkite atitinkamomis kryptimis (aukštyn, žemyn, kairėn, dešinėn).
    • Alternatively, employ the h, j, k, and l keys for left, down, up, and right movements, respectively.
  • Žodžių navigacija:
    • 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.
  • Navigacijos linijos:
    • Go to the start of the line by pressing 0.
    • Move to the end of the line with $.

Teksto redagavimas VIM

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

  • Įterpimo režimo įjungimas:
    • 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 leidžia pridėti eilutės pabaigoje.
  • Teksto ištrynimas:
    • 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.
  • Kopijuoti ir įklijuoti:
    • Copy a line with yy.
    • Paste the copied line below the current line using p.
  • Anuliuoti ir perdaryti:
    • Undo the last action with u.
    • Redo with Ctrl + r.

Ieškoma VIM

Veiksminga paieška yra labai svarbi. Štai keletas su paieška susijusių sparčiųjų klavišų:

  • Ieškau teksto:
    • 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.
  • Teksto pakeitimas:
    • Substitute the current word with a new one using :s/old/new/g.

Išeina iš Vim

Pradžioje jau aprašiau pagrindus, bet čia yra dar keletas variantų:

  • Išsaugoti ir uždaryti viską:
    • To save all changes and quit multiple files simultaneously, use :wa ir :qa.
  • Išėjimas neišsaugojus:
    • If you want to exit Vim without saving any changes made in any of the files, :qa! will do the trick.

Išvada

Atminkite, kad Vim įvaldymas reikalauja laiko ir praktikos. Kuo daugiau naudosite, tuo patogesnis ir galingesnis jis bus. Sėkmingo redagavimo!