Exit neon sign on brick wall background

كيفية الخروج من VIM واختصارات VIM الأكثر شهرة

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 باستخدام مجموعات المفاتيح

يعد محرر Vim أمرًا صعبًا للمبتدئين، ولكن عندما تتعلم مجموعات المفاتيح الصحيحة، يصبح استخدام VIM أمرًا سهلاً. فيما يلي مجموعات المفاتيح الأكثر شيوعًا لإنهاء vim.

الخروج من حفظ التغييرات vim

للخروج من vim مع حفظ التغييرات اضغط خروج للخروج من وضع التحرير، ثم اضغط باستمرار يحول واضغط القولون 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!
exit vim without saving changes
الخروج من vim مع عدم حفظ أي تغييرات

احفظ التغييرات بدون محرر 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

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

  • تحريك المؤشر:
    • استخدم مفاتيح الأسهم للتحرك في الاتجاهات المعنية (أعلى، أسفل، يسار، يمين).
    • Alternatively, employ the h, j, k, and l keys for left, down, up, and right movements, respectively.
  • التنقل بالكلمات:
    • 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.
  • خطوط التنقل:
    • Go to the start of the line by pressing 0.
    • Move to the end of the line with $.

تحرير النص في VIM

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

  • الدخول في وضع الإدراج:
    • 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 يسمح بالإلحاق في نهاية السطر.
  • حذف النص:
    • 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.
  • النسخ واللصق:
    • Copy a line with yy.
    • Paste the copied line below the current line using p.
  • التراجع والإعادة:
    • Undo the last action with u.
    • Redo with Ctrl + r.

البحث في VIM

البحث الفعال أمر بالغ الأهمية. فيما يلي بعض الاختصارات المتعلقة بالبحث:

  • البحث عن النص:
    • 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.
  • استبدال النص:
    • Substitute the current word with a new one using :s/old/new/g.

الخروج من فيم

لقد قمت بالفعل بتغطية الأساسيات في البداية، ولكن إليك بعض الخيارات الإضافية:

  • حفظ وإنهاء الكل:
    • To save all changes and quit multiple files simultaneously, use :wa و :qa.
  • الخروج بدون حفظ:
    • If you want to exit Vim without saving any changes made in any of the files, :qa! will do the trick.

خاتمة

تذكر أن إتقان Vim يستغرق وقتًا وممارسة. كلما استخدمته أكثر، أصبح أكثر راحة وقوة. تحرير سعيد!