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.
Κλείστε το πρόγραμμα επεξεργασίας VIM χρησιμοποιώντας συνδυασμούς πλήκτρων
Το πρόγραμμα επεξεργασίας Vim είναι δύσκολο για αρχάριους, αλλά όταν μαθαίνετε σωστούς συνδυασμούς πλήκτρων χρησιμοποιώντας το VIM γίνεται εύκολο. Εδώ είναι οι πιο δημοφιλείς συνδυασμοί πλήκτρων για να σταματήσετε το vim.
Έξοδος από τις αλλαγές αποθήκευσης vim
Για έξοδο από το vim με αποθήκευση αλλαγών, πατήστε Esc πλήκτρο για έξοδο από τη λειτουργία επεξεργασίας και, στη συνέχεια, κρατήστε πατημένο Μετατόπιση και πατήστε άνω και κάτω τελεία key (:). Then enter “wq” and press Enter. Here “w” stands for write and “q” stands for “quit”. On US keyboards the colon : είναι το ίδιο κλειδί με το ερωτηματικό ;, located right of the letter “L” key.
:wq
Έξοδος από το vim χωρίς αποθήκευση αλλαγών
To exit vim without saving changes hold down Shift and press the colon key (:). Then enter “q!” and press Enter.
:q!

Αποθηκεύστε τις αλλαγές χωρίς τον υπάρχοντα επεξεργαστή VIM
To save changes without exiting vim hold down Shift and press the colon key (:). Then enter “w” and press Enter.
:w
Εξοικείωση με το VIM
Τώρα, όταν κάλυψα τα βασικά της εξόδου από το Vim και την αποθήκευση των αλλαγών, ας προχωρήσουμε σε ορισμένες πρόσθετες χρήσιμες συντομεύσεις και δυνατότητες του Vim για να βελτιώσετε την επάρκειά σας.
Εκκίνηση του VIM για την επεξεργασία του αρχείου
Συνήθως οι προγραμματιστές εκκινούν το vim για να επεξεργαστούν το αρχείο χρησιμοποιώντας την εντολή:
vim filename
Εάν το αρχείο λείπει, θα δημιουργηθεί. Μπορείτε να καθορίσετε πολλά αρχεία για επεξεργασία:
vim file1 file2 file3
Για να ανοίξετε αρχείο σε συγκεκριμένη γραμμή, μπορείτε να προσθέσετε [num] μετά την εντολή vim. Για παράδειγμα, για να ανοίξετε το αρχείο στη γραμμή 127, πληκτρολογήστε:
vim filename +127
Πλοήγηση σε VIM
Once you’ve entered Vim, navigating efficiently is key. Here are some popular shortcuts:
- Μετακίνηση του δρομέα:
- Χρησιμοποιήστε τα πλήκτρα βέλους για να μετακινηθείτε προς τις αντίστοιχες κατευθύνσεις (πάνω, κάτω, αριστερά, δεξιά).
- Alternatively, employ the
h,j,k, andlkeys for left, down, up, and right movements, respectively.
- Πλοήγηση στο Word:
- 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.
- Move the cursor to the beginning of the next word with
- Γραμμές πλοήγησης:
- Go to the start of the line by pressing
0. - Move to the end of the line with
$.
- Go to the start of the line by pressing
Επεξεργασία κειμένου σε VIM
Once you’ve reached the desired location, these shortcuts will aid in text manipulation:
- Εισαγωγή στη λειτουργία εισαγωγής:
- Press
ito enter insert mode before the cursor. - Use
Ito start inserting at the beginning of the line. - Employ
ato append after the cursor. Aεπιτρέπει την προσάρτηση στο τέλος της γραμμής.
- Press
- Διαγραφή κειμένου:
- 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.
- Delete the character under the cursor with
- Αντιγραφή και επικόλληση:
- Copy a line with
yy. - Paste the copied line below the current line using
p.
- Copy a line with
- Αναίρεση και επανάληψη:
- Undo the last action with
u. - Redo with
Ctrl + r.
- Undo the last action with
Αναζήτηση στο VIM
Η αποτελεσματική αναζήτηση είναι ζωτικής σημασίας. Ακολουθούν ορισμένες συντομεύσεις που σχετίζονται με την αναζήτηση:
- Αναζήτηση κειμένου:
- Initiate a search with
/, followed by the desired term. - Use
nto jump to the next occurrence andNto go to the previous one.
- Initiate a search with
- Αντικατάσταση κειμένου:
- Substitute the current word with a new one using
:s/old/new/g.
- Substitute the current word with a new one using
Έξοδος από το Vim
Έχω ήδη καλύψει τα βασικά στην αρχή, αλλά εδώ είναι μερικές ακόμη επιλογές:
- Αποθήκευση και έξοδος όλων:
- To save all changes and quit multiple files simultaneously, use
:waκαι:qa.
- To save all changes and quit multiple files simultaneously, use
- Έξοδος χωρίς αποθήκευση:
- If you want to exit Vim without saving any changes made in any of the files,
:qa!will do the trick.
- If you want to exit Vim without saving any changes made in any of the files,
Σύναψη
Θυμηθείτε, η εκμάθηση του Vim απαιτεί χρόνο και εξάσκηση. Όσο περισσότερο το χρησιμοποιείτε, τόσο πιο άνετο και δυνατό γίνεται. Καλή επεξεργασία!






