מאז שהתחלתי להשתמש ב- Vim בשנת 2016, גיליתי כמה תכונות פחות מוכרות שמציעה Vim מהקופסה ללא תוספים.
האם אתה יכול לכסות כמה יסודות לפני שתתחיל להסתובב על הדברים החדשים האלה?
אה בטח! לפני שאעתיק להדביק כמה פקודות מגיליון צ'אט, אני הולך להניח הנחה מודגשת: לא היית קורא את זה אם אתה רוצה גיליון צ'אט וכבר ידעת את יסודות Vim.
אולי רק שמעת שהפצות לינוקס מועברות עם עורך טקסט ברירת מחדל של שורת פקודה בשם Vim,ואולי תרצה פשוט לנסות.
אז נניח שאתה חדש לגמרי בכל המשחק הזה והתחל ממה שאנחנו צריכים כבסיסים (ללא היסטוריה / תיאוריה משעממת).
הערה: אם אתה יודע את היסודות, לחץ כאן כדי לגלול מעבר להםמה העסקה שלך כאן לעומת טונות של מאמרים אחרים ב- Vim?
מרבית מאמרי המבוא ב- Vim מתחילים במצבים של Vim, הכנסה, שמירה ויציאה. אם אתה באמת במצב רוח של מצב למידה לשלמות תיאורטית, אל תהסס לקרוא את כל מה שעוזר ב- Wikibooks.
יש גם כמה ספרים ומאמרים מעולים שאומרים לך שיש פילוסופיה מאחורי הדרך שבה Vim עובד ושהפקודות ב- VI / Vim נועדו לשלב. נכון לחלוטין ואני בטוח שתעריך את זה ברגע שתתרגל לעורך ולכוח שהוא מספק.
שמעתי סיפורים מצחיקים וראיתי תמונות מצחיקות על עקומת הלמידה של Vim. האם זה נכון? האם זה באמת כל כך גרוע?
ובכן, שונאים הולכים לשנוא? עם זאת, לטענתי, הדימוי שקצת מייצג ייצוג נכון של Vim הוא:

רוב המאמרים ב- Vim מתייחסים לעקומת הלמידה * כאל קיר * למידה, אבל היי, יש איזו חיוביות: הביטו בצד השני של הקיר!
למתחילים זה ממש קיר שכן הם מעולם לא עשו דבר כזה לפני כן להשתמש בעורך בשורת הפקודה. הדבר שהכי מושך אותי כשהתחלתי כמתחיל היה בכל מקום של Vim.
היכנס לכל מכונה (שאינה חלונות) מכל מסוף ותוכל ממש להשיג עורך על ידי הקלדת * vi * בעיניים עצומות. העורך יופיע לפניך!
דבר נוסף שמושך אותי הוא היכולת לעבוד בלי עכבר ובלי לבזבז זמן פרודוקטיבי על לוח המגע או להשיג עכבר למחשב נייד.
אני יודע, אני יודע, אני יכול לשמוע כמה מכם צועקים "אמקס! אמאקס! " אני מבין. אבל ברגע שהתחברתי ל- Vim, פשוט מעולם לא היה לי שום עניין באמקים (יכול להיות בגלל ההתקנה הנדרשת). אז, כן emacs הוא גם נהדר אני מניח. אל תהסס לקפוץ לספינה לפני שתתחיל לשוט למסע היפה הזה עם VI (m).
פשוט פתחתי את הטרמינל שלי והקלדתי vi והקשתי על מקש Return. כל מה שאני רואה הוא מסך קבלת פנים. אני לא יכול להקליד ואני לא יודע איך לצאת מזה. האם אתה בטוח שזה עורך חזק עם יכולות?
בטוח ב 100%. ההתנהגות שרק היית עדה אליה היא * הקיר * שראינו קודם. תאמין לי VI (m) יכול לעשות הרבה דברים אחרים. פשוט יש לו דרכים משלו להשתמש בו. באפשרותך לערוך קבצים, לפתוח כרטיסיות, לפצל את המסך בצורה אופקית או אנכית, לגלוש במערכת הקבצים, להריץ פקודות לינוקס מבלי לעזוב את הקובץ, להפעיל ביצוע מבנים מקוד המקור שלך מבלי לצאת מהקובץ, ספריות סימניות, אפילו יותר טוב: שורות סימניות של קובץ, מצא והחלף מילים, כמובן העתק והדבק ועוד.
כֵּן! כאילו שזה עניין גדול שעורך יתמוך בכך. מה! כולם עושים את זה. מה העניין הגדול?
אין עניין גדול, העסקה היחידה שאני רואה היא היכולת להתמקד בקובץ / קוד שלך מבלי לעזוב את המקלדת. באמת, אם לא אכפת לך להשתמש בעכבר, קדימה ופתח את עורך ה- word / GUI שלך ב- MS ובצע את כל העריכה שתרצה לעשות.
מספיק הוגן. אבל, ברצינות למה לא IDE לעבודה כלשהי?
אוקיי, אז אתה מפתח והיה לך חיבה / אהבה ל- IDE. לא, VI (m) אינו תחליף ל- IDE המבריק שלך. ל- VI (m) אין יכולות מדהימות מהקופסה של ה- IDE שלך. VI (m) הוא רק בגודל קטן (חבילה והתקנה) בהשוואה ל- IDE מגושם וזמין לשימוש ללא כל תצורה והתקנה. ברצינות, VI (מ ') אינו תואם לכמה דברים נהדרים שה- IDE שלך מספק.
די לדבר, הראה לי את היסודות?
בטח, לפני שתתחיל, רק צריך לזכור שכל משתמש Vim צריך בעצם להתמודד עם מצב פקודה ומצב הכנסה. אין מנוס (תרתי משמע, לא מקש Esc).
נניח שאתה משתמש בעורך כלשהו וברצונך למחוק פונקציה ארוכה בשפת C. הצעדים הפשוטים שאתה עושה הם: מקם את הסמן בתחילת השורה, ואז לחץ על Shift + חץ למטה עד הסוף או השתמש בעכבר. פעולה זו שעליך לעשות כדי לבחור את השורות הללו דרשה ממך * להפסיק * להקליד וללחוץ על מקשים. נכון? אל תגיד לי שהקלדת משהו ולחצת בו זמנית על מקשים כדי לבחור בצורה קסומה את גוף הפונקציה שלך.
תהיה הגיוני. השהיתם את ההקלדה וביצעתם את הבחירה בכדי לומר לעורך שלכם שאתם רוצים לעשות משהו עם הטקסט הזה (העתק / גזור / מודגש / נטוי / כל דבר).הפסקה זו שלקחת שווה להיות במצב פקודה ב- VI (m). זה הזמן שבו אתה אומר ל- VI (m) שאתה רוצה לעשות כמה פעולות בשורות / מילה / כלום כלשהו ואתה לא מתכוון להקליד. כעת, VI (מ ') מוציא אותך ממצב ההוספה ואתה נעול מהקלדת טקסט בקובץ שלך. ברור שהמצב האחר שבו אתה באמת יכול להקליד את הקובץ שלך הוא מצב ההוספה.
אם כן, אם תהיתם כיצד אתם בוחרים גוף פונקציה מבלי לבחור טקסט או להשתמש בעכבר, אני משיג זאת על ידי הצבת הסמן על הפלטה הפותחת ושימוש בלחיצות מקשים: d%
כן, זה מוחק את התוכן של גוף התפקוד שלך. לא, זה לא איזה שילוב מצמרר של מקשים לזכור! d
מציין שאתה רוצה למחוק משהו. %
עומד להזיז את הסמן לסוף הסוגר התואם.
כעת, לאחר שקבענו את המצבים הבסיסיים, בואו נצלול לתוך VI (m) בסיסי.
אם אתה יודע את שם הקובץ שאתה כותב:
$ vi myfile.c
אם אינך בטוח בשם הקובץ וברצונך להתחיל להקליד:
$ vi
ברגע שתפתח vi, תהיה במצב פקודה. כדי להזין i nsert מצב, העיתונות i
. הקלד כל מה שתרצה. לחץ Esc
כדי לחזור למצב פקודה. עכשיו יש לך כמה אפשרויות לצאת בהתאם לאופן שבו פתחת vi.
אם נתת שם הקובץ: :w
רצון w טקס שינויים אלה בבטחה בדיסק. :q
יהיה q מתוך העורך. ניתן לשלב פעולות אלה עם: :wq
ו Return
מפתח
אם אתה לא נותן שם קובץ: :wq filename.c
רצון w טקס התכנים לקובץ filename.c
ו q uit העורך. אם אינך מעוניין בטקסט שכתבת ורוצה לצאת מבלי לשמור דבר: :q!
ואתה בחוץ! !
נדרש בסוף לומר: "כן, אני בטוח שאני לא רוצה לשמור את התוכן ואני רוצה לצאת בדחיפות"
[DEMO] שימוש בסיסי ב- vim
להפעלת עורך ה- vim: השתמש בפקודה vim במעטפת כדי להתחיל בעריכת קובץ באמצעות vim, השתמש ב: שם הקובץ vim asciinema.org
הנה לך! רק יצרת, ערכת ושמרת (או אולי לא) את קובץ ה- vi הראשון שלך. מזל טוב ?
כפי שציינתי קודם, זו אינה מבוא למתחילים ל- VI (m). יש הרבה מאמרים אחרים (אני אספק סימוכין בסוף המאמר) כדי להתחיל. פשוט הכנסתי את המבוא הזה כדי שלא תתאכזב אחרי שנחתת בדף הזה ולא מצאתי מה ללמוד?
זה השורה שבה מתחילים נפרדים ממשתמשי ביניים ועוברים לחלק העיון למאמרי מבוא מבריקים יותר.ברוך הבא למשתמשי הביניים. אלה כמה יכולות מגניבות של VI (m) שלא הייתי מודע להן. אבל עכשיו אני משתמש בהם מדי יום כדי להיות פרודוקטיביים יותר.
לאלו מכם שמעדיפים TL; DR:
- דפי לשוניות
- הפעלות
- מספרי שורות (+ סימנים) והעתקה / הדבקה
- קיפולים
- כוונה עם
=
- הוספת השלמה
- netrw
- פיצולים / חלונות
:!
וקצת על:make
כרטיסיות Vim
האם הזכרת כרטיסיות ב- Vim? לא ידעתי שקיים!
I know, right! A tab page is a page with one or more windows with a label (aka tab) at the top.
If you are interested in knowing more about windows, buffers, tab pages: technical details
Have a look:



Steps:
- Open Vim with any file or just Vim:
$ vim file1
- Type the contents of file and get into command mode (Press
Esc
) :tabedit file2
, will open a new tab and take you to editfile2
:tabedit file3
, will open a new tab and take you to editfile3
- To navigate between these tabs, you can be in normal mode and type :
gt
orgT
to go to next tab or previous tab respectively. You can also navigate to a particular index tab (indexed from 1) using{i}gt
where, i is the index of your tab. Example:2gt
takes you to 2nd tab - To directly move to first tab or last tab, you can enter the following in command mode:
:tabfirst
or:tablast
for first or last tab respectively. To move back and forth ::tabn
for next tab and:tabp
for previous tab - You can list all the open tabs using :
:tabs
- To open multiple files in tabs:
$ vim -p source.c source.h
- To close a single tab:
:tabclose
and to close all other tabs except the current one::tabonly
. Use the suffix!
to override changes of unsaved files
[DEMO] Tabs in VIM
VIM supports tabs to open multiple files and work with themasciinema.org
I think this feature enables us to effectively save time by sharing the buffer between tabs and enabling us to copy paste between tabs and keep multiple sessions of different tab set for category of work. Example: You can have a terminal tab with all Vim tabs of source code C files only and you can have another terminal tab with all Vim tabs of header files (.h).
Tabs provide so much convenience to keep all my files open and access them when I want. However, isn’t it a pain to open all tabs every time I reboot or close and open the terminal?
Right! We all like to have our own sessions of work in which we work with a set of files and would like Vim to restore that session of tabs the way we left it.
Vim allows us to save and restore those tab sessions! ✋
Steps:
- Open any number of tabs you wish to work with
- From any tab, press
Esc
and enter the command mode - Type
:mksession header-files-work.vim
and hit enter - Your current session of open tabs will be stored in a file
header-files-work.vim
- To see restore in action, close all tabs and Vim
- Either start vim with your session using :
$ vim -S header-files-work.vim
or open vim with any other file and enter command mode to type::source header-files-work.vim
and BOOM! All your tabs are opened for you just the way you saved it! - If you change any session tabs (close/open new), you can save that back using :
:mks!
while you are in the session
[DEMO] Sessions in VIM
VIM allows users to store their work sessions separately based on the projects they are working on. Users can easily…asciinema.org
Can I copy/cut paste without having to know line numbers?
אה כן! מוקדם יותר הייתי רואה את מספרי השורות ( :set nu
) של הפונקציות שרציתי להעתיק / לגזור. נניח שאני רוצה להעתיק / לחתוך את השורות 34 עד 65. השתמשתי :34,65y
(Copy / Y ank) או :34,65d
(Cut / D elete).
{n}yy
או
{n}dd
(היכן
n
מספר השורות) אינן אפשרות למאות שורות?
יכולות להיות כמה פונקציות המשתרעות על פני מספר עמודים ואתה לא רוצה לרדת רק כדי לשכוח מה היה מספר השורה הראשונה. יש דרך פשוטה להשיג זאת מבלי לדאוג לשום דבר לגבי מספרי קווים!
צעדים:
- היכנס למצב רגיל, עבור לשורת ההתחלה
- הקלד
mk
(סמן נקודה עם האלף-בית 'k' או השתמש בכל אלפבית אחר) - עברו למטה (דף למטה או מה שלא יהיה) ועברו לשורת הסיום
y'k
will yank/copy all the lines from start to endd'k
will cut/delete all the lines from start to end
I have some annoying long functions at the top of my file and I don’t want to waste my time scrolling or jumping to lines. This may be a lot to ask because this is not an IDE but, by any chance can we fold the code blocks?
Absolutely! Let’s say you want to skip remembering those line numbers and walk around with your new found love *the markers*. Go to the beginning of the function body and type mb
. Now, just go to the end of the function body using %
(brace matching) or any other convenient technique and press zf'b
and you’re done!
Before and after:


If you are comfortable using the line numbers, the command is even easier to remember: :5,16fo
(fo stands for code fold). Once you have folded your code, it’s easy to toggle between open and closed views using zo
(Open the code fold) and zc
(Close the code fold). Don’t stress it so much. Just use za
to toggle between open and closed folds ?
Let’s say you spent considerable time folding your functions in a large file, you would obviously want to retain those folds every time you open that file right? (If not, why did you waste your energy folding them!?), so there’s a solution right in your ~/.vimrc
. Insert the following lines in ~/.vimrc
and your code folds are saved and restored:
autocmd BufWinLeave *.* mkview autocmd BufWinEnter *.* silent loadview
I’m usually careful with my indentation but sometimes, I have to edit some other idiot’s source code and it bugs me to edit his/her code without indentation. Are there any magical keystrokes to make that happen?
Sure! It’s as simple as: =i{
. Really that’s all ! ( i is inner object)
[DEMO] Indentation in VIM
VIM allows blocks of code to be indented with a few keystrokes. All you have to do is place the cursor in a block of…asciinema.org
Before-after:


All you have to do is place the cursor anywhere within a block you want to indent, press Esc
to enter normal mode and then: =i{
. Boom! Your entire function body (including inner blocks) is indented.
ניתן גם להגדיל / להקטין את הכניסה בתוך בלוק באמצעות:; >
i {כדי להגדיל and
אולי אני חולם אבל (* קול רוטט *), זאת אומרת אני רק רוצה לנסות את זה, אהממ, אולי אני דוחף את זה ממש רחוק עם זה אבל (* הפסקה של 5 שניות *) .. לא משנה, מאפשר לנו לזוז לשאלה הבאה שלי
Vim די פתוח לפתוח ביקורת או להתמודד עם העובדה שזה לא IDE, קדימה, בוא נראה מה יש לך.
אהממ, סליחה אבל במקרה (* מתנשף *) עם כל תוסף או משהו כזה, האם ל- vim יש השלמה אוטומטית כמו IDE?
? אתה יכול להיות מופתע אבל כן כן! ? ונחש מה…
* לחמניות תוף *
* לחמניות תוף *
* לחמניות תוף *
* לחמניות תוף *
ללא תוסף!
שמעת אותי נכון! התנאי היחיד ש- Vim יציג בפניך אפשרויות הוא "Vim צריך לדעת על מה אתה מדבר." זה יכול להיות באמצעות קובץ מקור כלול או פונקציות או משתנים מוגדרים.
כל שעליך לעשות הוא להתחיל להקליד ואז ללחוץ Ctrl+n
במצב הוספה.



רק דמיין את השימושים! במיוחד אם אתה כותב קוד C ואינך יכול לזכור את שיחת ספריית OpenSSL המדויקת, כל שעליך לעשות הוא לכלול את הכותרת!
[DEMO] תכונה להשלמה אוטומטית ב- VIM
ל- VIM יש הצעות להשלמה אוטומטית למילות מפתח, שמות פונקציות אם כלולים קבצי הכותרת המתאימים או אם ... asciinema.org

הרשו לי להזכיר שוב: אין צורך בתוספים?
הערה: ייתכן שקובצי הכותרת נמצאים במקומות אחרים ב- Mac וייתכן ש- Vim לא יוכל למצוא אותם. אני פשוט משתמש ב- Mac כדי להתחבר למכונת לינוקס. אז אם אתה משתמש ב- Mac, מצטער על כך.I understand Vim is just a text editor but if you want me to work without losing focus and without exiting Vim every now and then, what options do I have if I can’t remember all the file names?
Simple, use the file explorer provided by VIM ? Yes, Vim provides a simple file explorer (*without any plugins*). Just type : :Explore
from any Vim window and you will see an easy to navigate file explorer which can be navigated using ⬆️ and ⬇️ arrow keys. Press Enter/Return
key to open a file/directory. Use :q
to exit the explorer and vim. If you do not wish to quit vim and continue working with an open file, you have 3 options:
- Open the explorer in a horizontal (
:Sexplore
) or vertical (:Vexplore
) split and exit the explorer using:q
- פתח את הסייר בדף כרטיסייה אחר באמצעות
:Texplore
וצא באמצעות:q
- פתח את סייר הקבצים בחלון הנוכחי שלך ואז פרוק את המאגר הנוכחי ומחק אותו מרשימת המאגר באמצעות
:bdel
(מחיקת מאגר).

:Ex
כדי לפתוח את סייר הקבצים
לפעמים אני צריך לחזור על אותם צעדים בכמה שורות כדי לערוך משהו. אני די בטוח של- Vim תהיה תכונה כלשהי שתאפשר לי לעשות זאת. האם אני צודק?
100% צודק! אתה מדבר על פקודות מאקרו ו- Vim תומך במאקרו. חזרה על הפקודה שבוצעה לאחרונה היא פשוטה ויכולה לבצע משימות פשוטות שחוזרות על עצמן. עם זאת, אם עיבוד הטקסט מורכב ממספר שלבים להשגת תוצאה, פקודות מאקרו שימושיות.
שקול דוגמה לקובץ כותרת C:
void encrypt_text(char *text, int bytes) void decrypt_text(char *text, int bytes) void process_text(char *text, int bytes) void another_important_function(int bytes, double precision)
Oops! You forgot to put a semicolon at the end of each line and also you just realized that all these functions return an integer error code instead of void.
The steps you need to perform for making change in one line are:
- Place the cursor at the beginning of the word
void
- Press
cw
in normal mode to delete the wordvoid
and typeint
- Press
Esc
, move to the end of line usingShift+a
to insert;
- Press
Esc
and press^
to return to the beginning of the edited line
Resulting in:
int encrypt_text(char *text, int bytes); void decrypt_text(char *text, int bytes) void process_text(char *text, int bytes) void another_important_function(int bytes, double precision)
You can just record this sequence of steps and replay it on all 4 lines.
All you have to do is, before you start the sequence, start recording the macro in any alphabet (let’s say a
) by pressing qa
in normal mode. Now your steps are being recorded in a
. Once you are done with all your steps, just press q
in normal mode. This will end the recording. To replay these steps, just keep the cursor at the same place where it was placed during macro. Press @a
and we’re done! BOOM! Vim will repeat the same steps for you on that line! To repeat it on multiple lines, you can also use @@
after using @a
command once
I know Vim is nowhere close to an IDE and I may be having some unreasonable hopes but just a quick question: Remote editing of files possible with Vim?
If you think of it considering the available resources:
[1] Vim
[2] openssh-client (Comes installed with most Linux flavors)
You are in luck my friend! Yes, Vim supports remote editing of files ?
Vim just utilizes the secure connection established by scp (secure copy) provided by openssh-client. There are times when you are working with files on multiple remote machines and it’s a waste of time to log into a machine just to edit one single file! You can relax in your current machine if you just know your remote machine credentials and path.
vim scp://[email protected]_IP_or_hostname/relative/path/of/file
For example: I need to edit a file on 10.0.18.12 stored in /home/dev-john/project/src/main.c
and I have login credentials for dev-john
, I can access the main.c
using:
$ vim scp://[email protected]/project/src/main.c
I can use the relative path because, I can start looking for the file from the home directory of dev-john
TIP: If you access a remote machine frequently, you can create an ssh config file to create a shortcut for the connection. Create a file ~/.ssh/config
with
Host remote-dev-machine Hostname 10.0.18.12 User dev-john IdentityFile ~/.ssh/id_rsa
Now you can access your file using:
$ vim scp://remote-dev-machine/project/src/main.c
If it’s confusing to remember the relative path and not intuitive, you can also specify it with an alternative:
$ vim scp://remote-dev-machine/~dev-john/project/src/main.c
Awesome! I’m already thrilled at the out-of-the-box capabilities of Vim. Looks like you’ve a solution to a lot of common editing problems. Let’s see. I have a file with over 2000 lines and the functions of my interest are located at line 9, line 768 and line 1898. I know I can jump to a line using line number but I’m not so good at remembering those numbers. Got anything for me?
Hell yeah! What you’re looking for is a local bookmark solution in Vim using letters. All you have to do is :
- Place your cursor on any line at any position
- Press
Esc
to make sure you’re in normal mode - Press
m{lowercaseletter}
where{lowercaseletter}
is any letter froma-z
- You just created a local bookmark to navigate in your file
To view all your bookmarks: Press Esc
and enter command mode, type :marks
and hit Enter/Return
. You’ll see a list of your bookmarks. To visit any bookmark at any time, just press Esc
and type `{lowercaseletter}
. Kaboom! You’ll arrive at the exact same location with cursor where you bookmarked. Example:

I have created a local bookmark to line 21, column 18 using a
. If I’m editing something on line 1783, I would just press Esc
and type `a
:

To solve your problem, all you’ve to do is create 3 local bookmarks and quickly jump to them by looking at :marks
.
Problem solved ?
What if I told you that you can create global bookmarks too?! ? Yes, it is possible to create global bookmarks too! These are equivalent to your windows or GUI shortcuts (or linux soft/hardlinks) except you don’t need to create an actual link. You heard me right! You can literally jump from editing a file in /dir1
to another file and line in /project/src/
from your Vim without exiting ! ?
Fret not, it’s not a big new thing to remember. All you have to do is:
Use an uppercase letter instead of lower case letter to create a global bookmark. That’s all! Really! You navigate to the global bookmark using the same process. Example: If you’ve created a bookmark using mP
, all you’ve to do is press Esc
and type `P
and BAM! You jump to your global bookmark (Vim remembers the path, so you don’t have to type anything about the path)
You can access the global bookmarks in the same way as local : :marks
:marks mark line col file/text P 53 4 ~/project/src/large-file.c A 11 0 ~/project/README.md
NOTE: If you are not interested in the cursor position and just want to be there at the beginning of you bookmarked line, use 'P
instead of `P
(Use a single quote instead of back tick to be positioned at the beginning of the line)
I’ve heard that Vim supports window splitting along with tabs! I understand tabs are great and you get to work with multiple open files at once. But, what about splitting? Why would I want that?
Scenarios:
- You may want to edit a file by looking at another file simultaneously (May be you are defining a C function by looking at it’s declaration in a header file)
- You may want to edit some portion of a file by looking at the top/bottom portion of the same file simultaneously
- Your work may require you to edit a file by looking at different portions of different files simultaneously
Vim supports splitting of screen both horizontally and vertically. Even better, you can even browse file system to open a file when you split your screen.
Here are the available options:
:split filename - split window horizontally and load filename :vsplit file - vertical split and open file ctrl-w up arrow - move cursor up a window ctrl-w ctrl-w - move cursor to another window (cycle) ctrl-w _ - maximize current window vertically ctrl-w | - maximize current window horizontally ctrl-w = - make all equal size :sview file - same as split, but readonly :close - close current window



Maximizing a window for work:

Resizing:
CTRL-W [N] - Decrease current window height by N (default 1) CTRL-W [N] + Increase current window height by N (default 1) CTRL-W [N] Increase current window width by N (default 1)
Is there a way to use file explorer while I split panes? (I can’t remember and type the file names always!)
Of course, all you have to do is type : :Sexplore
for horizontal file explorer and :Vexplore
for vertical file explorer. You can also use :Vexplore!
to open the file explorer on right side (instead of default left)
Again, all this works *without any extra plugins* ?
I am in the middle of editing some code and I quickly need to run a shell command. Should I save my work, exit Vim and run my commands? I bet there is a better way out with Vim
You bet! Vim just doesn’t want you to leave Vim and wants you to continue focussing on your work. Hence the option to execute shell commands from within your Vim. Don’t worry, all your unsaved work is not discarded, you just execute your command and BAM! you are back in your unsaved/saved file safely!
Let’s say you are in the middle of a coding session and you quickly need to head out to take a look at man page of file operations because you forgot the signature! You don’t have to save your work, exit Vim and then check man pages or you don’t have to open another tab just for the man page. You can issue the command from right within the Vim editor.
[DEMO] Unix commands from VIM
VIM allows users to execute shell commands from within VIM without exiting. All you have to do is enter the command…asciinema.org



Guess what! Prepare to be amazed. Vim also supports make
command from within your file! All you have to do is navigate to a directory with Makefile
. Open any file (Could be your source code) and make all the changes and save it. Wait, there’s no need to exit to see the compilation result. You can trigger your make build from right within Vim:
[DEMO] Trigger make builds from vim
VIM allows users to trigger make builds without exiting VIM. All we have to do is enter the command mode and type :makeasciinema.org



Similarly you can build other targets in your Makefile!
Example: Build directory clean up



I hope these cool features will help you to use Vim more productively.
Your feedback is always welcome.
Feel free to comment, criticize or applaud ?
References:
- //www.openvim.com/tutorial.html
- //linuxconfig.org/vim-tutorial
- ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf
- //vim.wikia.com/wiki/Tutorial
- //www.viemu.com/a-why-vi-vim.html
- //robertames.com/files/vim-editing.html
- //www.youtube.com/watch?v=wlR5gYd6um0