Miért szeretem a Vim-et: A kevésbé ismert funkciók teszik annyira csodálatosá

Amióta 2016-ban elkezdtem használni a Vim-et, számos kevésbé ismert funkciót fedeztem fel, amelyeket a Vim plug-inek nélkül kínál a dobozból.

Tudna átfogni néhány alapot, mielőtt elkezdene rágódni ezekről az új dolgokról?

Oh biztos! Mielőtt bemásolnék néhány parancsot egy cheatsheet-ből, merész feltételezést fogok tenni: Ön nem olvassa el ezt, ha cheatsheet-et szeretne, és már ismeri a Vim alapjait.

Lehet, hogy most hallotta, hogy a Linux disztribúciók egy alapértelmezett Vim nevű parancssori szövegszerkesztővel szállítanak,és érdemes csak kipróbálni.

Tehát tegyük fel, hogy teljesen új vagy ebben az egész játékban, és csak abból indulj ki, amire szükségünk van alapként (történelem / unalmas elmélet nélkül).

MEGJEGYZÉS: Ha ismeri az alapokat, kattintson ide, hogy végiggörgethesse azokat

Mi a te ügyed itt a Vimről szóló rengeteg más cikkhez képest?

A Vim-ről szóló bevezető cikkek többsége a Vim módjaival kezdődik, beszúrással, mentéssel és kilépéssel. Ha valóban az elméleti tökéletesség tanulási mód kedveli, olvassa el bátran, ami segít a wikikönyvekben.

Van néhány remek könyv és cikk is, amelyek azt mondják, hogy a Vim működése mögött filozófia áll, és hogy a VI / Vim parancsai kombinálva vannak. Teljesen igaz, és biztos vagyok benne, hogy értékelni fogja, ha megszokja a szerkesztőt és az általa nyújtott hatalmat.

Vicces történeteket hallottam és vicces képeket láttam a Vim görbéjének tanulásáról. Igaz ez? Tényleg olyan rossz?

Nos, a gyűlölködők utálni fogják? Szerintem azonban az a kép, amely némileg megfelelő ábrázolást nyújt Vimről, a következő:

A Vim-ről szóló cikkek többsége a tanulási * görbét * tanulási * falnak nevezi, de hé, van némi pozitívum: nézd meg a fal másik oldalát!

A kezdőknek ez szó szerint egy fal, mivel még soha nem csináltak hasonlót, hogy szerkesztőt használjanak a parancssorban. Amikor kezdőként kezdtem, az vonzott leginkább engem, hogy Vim mindenütt jelen van.

Jelentkezzen be bármely (nem Windows) gépre bármely terminálról, és szó szerint megszerezhet egy szerkesztőt, ha csukott szemmel írja be a * vi * szót. A szerkesztő megjelenik előtted!

Egy másik dolog, ami vonzó volt számomra, az a képesség, hogy egér nélkül dolgozhatok, anélkül, hogy produktív időt pazarolnék az érintőpadra, vagy hogy egeret szereznék laptophoz.

Tudom, tudom, hallom, ahogyan azt kiabáljátok, hogy „Emacs! Emacs! ” Értem. De ha egyszer belekötöttem a Vimbe, akkor soha nem volt igazán érdekelt az emacs iránt (lehet, hogy a szükséges telepítés miatt). Szóval, igen, az emacs is remek gondolom. Nyugodtan ugorjon hajóra, mielőtt hajózni kezdene ezen a gyönyörű utazáson a VI (m) -nel.

Most kinyitottam a terminálomat, és beírtam a vi-t, és megnyomtam a return billentyűt. Csak egy üdvözlő képernyőt látok. Nem tudok gépelni, és nem tudom, hogyan kerüljek ki belőle. Biztos, hogy ez egy hatékony szerkesztő, képességekkel?

100% -ig biztos. Az a viselkedés, aminek éppen tanúja volt, az a * fal *, amelyet korábban láttunk. Bízz bennem, VI (m) sok minden másra képes. Csak megvannak a maga felhasználási módjai. Szerkesztheti a fájlokat, megnyithatja a füleket, vízszintesen vagy függőlegesen oszthatja meg a képernyőt, böngészhet a fájlrendszerben, futtathatja a linux parancsokat a fájl elhagyása nélkül, kiválaszthatja a forráskód összeépítését a fájlból való kilépés nélkül, könyvjelző könyvtárakat, még jobb: a fájl könyvjelző sorai, szavak keresése és cseréje, természetesen copy-paste és még sok más.

Igen! Mintha egy szerkesztő számára nagy baj, hogy ezeket támogassa. Meh! Mindenki ezt csinálja. Mi a nagy baj?

Nincs nagy baj, az egyetlen dolog, amit látok, az a lehetőség, hogy a billentyűzet elhagyása nélkül a fájljára / kódjára fókuszálhatok. Tényleg, ha nem bánja az egér használatát, akkor nyissa meg az MS word / GUI szerkesztőt, és végezze el a kívánt szerkesztést.

Elfogadható. De komolyan, miért nem IDE valamilyen munkához?

Oké, tehát te fejlesztő vagy, és szereted / szereted egy IDE-t. Nem, a VI (m) nem helyettesíti a fényes IDE-t. A VI (m) nem rendelkezik az Ön IDE-jének fantasztikus képességeivel. A VI (m) csak kisméretű (csomag és telepítés), a terjedelmes IDE-khez képest, konfiguráció és telepítés nélkül használható. Komolyan mondom, hogy a VI (m) nem felel meg az IDE által nyújtott néhány nagyszerű dolognak.

Elég beszéd, mutasd meg az alapokat?

Persze, mielőtt elkezdené, ne feledje, hogy minden Vim felhasználónak alapvetően a parancs móddal és a beszúrási móddal kell foglalkoznia. Nincs menekvés (szó szerint, nem az Esc billentyű).

Tegyük fel, hogy valamilyen szerkesztőt használ, és törölni szeretne egy hosszú függvényt C nyelven. Az Ön egyszerű lépései: Helyezze a kurzort a sor elejére, majd nyomja le a Shift + Le nyíl a végéig, vagy használja az egeret. Ez a művelet, amelyet a sorok kiválasztásához kellett tennie, megkövetelte, hogy * hagyja abba a * gépelést és nyomja meg a gombokat. Ugye? Ne mondd, hogy gépeltél valamit, és egyszerre lenyomtad a gombokat, hogy varázslatosan kiválaszd a funkció törzsét.

Légy ésszerű. Szüneteltette a gépelést és elvégezte a kiválasztási munkát, hogy elmondja a szerkesztőnek, hogy valamit szeretne csinálni ezzel a szöveggel (másolás / kivágás / félkövér / dőlt betű / bármi).

Ez a szünet, amelyet Ön alkalmazott, megegyezik azzal, hogy parancs módban van a VI (m) -ben. Ez az az idő, amikor azt mondod a VI (m) -nek, hogy néhány sort / szót / bármit meg akarsz csinálni, és nem fogsz gépelni. Most a VI (m) kiszorítja a beillesztési módból, és nincs lehetősége a szöveg beírására a fájljában. Nyilvánvaló, hogy a másik mód, amelyben ténylegesen beírhatja a fájlt, a beszúrási mód.

BTW, ha kíváncsi lennél, hogyan választod ki a funkciót a szöveg kiválasztása vagy az egér használata nélkül, azt úgy hajtom végre, hogy a kurzort a nyitó zárójelekre helyezem és billentyűleütéseket használok: d%

Igen, ez törli a funkciótest tartalmát. Nem, ez nem valami hátborzongató billentyűkombináció, amire emlékezni kell! dazt jelzi, hogy törölni akar valamit. %a kurzort a megfelelő zárójel végére mozgatja.

Most, hogy létrehoztuk az alapmódokat, merüljünk el az alap VI (m) -ben.

Ha tudja az írt fájl nevét:

$ vi myfile.c

Ha nem biztos a fájl nevében, és el akarja kezdeni a gépelést:

$ vi

Amint megnyitja a vi-t, akkor parancs módban lesz. Belépni i nsert állapotban nyomjuk meg i. Írjon be bármit. A Escparanccsal való visszatéréshez nyomja meg a gombot. Most van néhány lehetőség a kilépéshez attól függően, hogy hogyan nyitotta meg vi.

Ha adott egy fájl neve: :wakarat w rítus ezeket a változásokat biztonságosan lemezre. q fel:q fogja használni a szerkesztõt. Kombinálhatja ezeket a műveleteket: és kulccsal:wqReturn

If you did not give a filename: :wq filename.c will write the contents to the file filename.c and quit the editor. If you are not interested in the text you wrote and wish to exit without saving anything: :q! and you are out! The ! is required at the end to say : “Yes, I am sure I don’t want to save the contents and I want to get out urgently”

[DEMO] Basic vim usage

To start the vim editor: Use vim command on shell To start editing a file using vim, use : vim filenameasciinema.org

There you go! You just created, edited and saved(or may be not) your first vi file. Congratulations ?

Mint korábban említettem, ez nem kezdő bevezető a VI (m) -be. Rengeteg más cikk (a cikk végén hivatkozást adok) az induláshoz. Csak azért illesztettem be a bevezetőt, hogy ne csalódjon, miután rátért erre az oldalra, és nem talál semmit, amit tanulnia kellene?

Ez az a sor, ahol a kezdők elbúcsúznak a köztes felhasználóktól, és rátérnek a referencia szakaszra, ahol ragyogóbb intro cikkeket találnak.

Üdvözöljük a köztes felhasználóknál. Ezek a VI (m) néhány jó képessége, amelyekről nem tudtam. De most naponta használom őket, hogy produktívabb legyek.

Azok számára, akik a TL; DR-t részesítik előnyben:

  • fül-oldalak
  • foglalkozások
  • sorszámok (+ jelölések) és másolás / beillesztés
  • redők
  • behúzás =
  • betét-kitöltés
  • netrw
  • hasít / ablak
  • :! és egy kicsit kb :make

Vim lapok

Megemlítette a Vim lapjait? Nem tudtam, hogy létezik!

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 edit file2
  • :tabedit file3 , will open a new tab and take you to edit file3
  • To navigate between these tabs, you can be in normal mode and type : gt or gT 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?

Ó, igen! Korábban láttam :set nua másolni / kivágni kívánt függvények sorszámát ( ). Tegyük fel, hogy a 34–65. Sorokat szeretném átmásolni / kivágni. Használtam :34,65y(Másolás / Y ank) vagy :34,65d(Vágás / D elete).

Természetesen a sorok számlálása és a ( {n}yyvagy a sorok száma) használata nem választható több száz sor esetén? {n}ddn

Vannak olyan funkciók, amelyek több oldalra is kiterjednek, és nem akar lemenni, csak elfelejteni, mi volt az első sor száma. Van egy egyszerű módja ennek elérésére anélkül, hogy bármi aggódna a sorszámok miatt!

Lépések:

  • Lépjen normál módba, menjen a rajtvonalra
  • Típus mk(jelölje meg a pontot „k” ábécével, vagy használjon bármilyen más ábécét)
  • Mozogjon lefelé (oldal lefelé vagy bármi más), és lépjen a végsorhoz
  • y'k will yank/copy all the lines from start to end
  • d'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 ~/.vimrcand 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.

MEGJEGYZÉS: Nem számít a python fájlok behúzására? Csak akkor működik, ha a Vim a nyitó és záró zárójel segítségével azonosíthatja a kezdetet és a véget)

A blokkon belüli behúzást növelheti / csökkentheti a;; >i {használatával az a növeléséheznd

Lehet, hogy álmodom, de (* remegő hang *), azt akarom mondani, hogy csak ki szeretném próbálni, Uhmm, lehet, hogy ezzel nagyon messzire tolom, de (* 5 másodperces szünet *) .. sebaj, mozogni enged a következő kérdésemre

Vim elég nyitott ahhoz, hogy kritikát fogadjon, vagy szembesüljön azzal a ténnyel, hogy ez nem IDE, folytassa, nézzük meg, mi van.

Uhmmm, sajnálom, de véletlenül (* lihegve *) bármilyen pluginnal vagy valamivel, van-e a vimnek automatikus kiegészítése, mint egy IDE?

? Lehet, hogy meglepődsz, de igen! ? és képzeld csak…

* dobtekercsek *

* dobtekercsek *

* dobtekercsek *

* dobtekercsek *

Bővítmény nélkül!

Jól hallottad! Az egyetlen feltétel, hogy a Vim megmutassa a lehetőségeket, az az, hogy "Vimnek tudnia kell, miről beszél." Lehet egy mellékelt forrásfájl vagy meghatározott függvények vagy változók révén.

Mindössze annyit kell tennie, hogy elkezdi gépelni, majd Ctrl+nbeszúrás módban nyomja meg.

Képzelje csak el a felhasználást! Különösen, ha C-kódot ír, és nem tudja felidézni a pontos OpenSSL könyvtárhívást, csak annyit kell tennie, hogy tartalmazza a fejlécet!

[DEMO] Automatikus kiegészítés szolgáltatás a VIM-ben

A VIM automatikusan kiegészíti a kulcsszavakat, a függvényneveket, ha a megfelelő fejlécfájlok szerepelnek, vagy ha a… asciinema.org

Hadd emlékeztessem még egyszer: Nincs szükség bővítményre?

MEGJEGYZÉS: A fejlécfájlok a Mac néhány más helyén lehetnek, és előfordulhat, hogy a Vim nem fogja megtalálni őket. Csak egy Mac-et használok, hogy belépjek egy linuxos gépbe. Tehát, ha Mac-et használ, sajnálja ezt.

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:

  1. Open the explorer in a horizontal ( :Sexplore ) or vertical ( :Vexplore ) split and exit the explorer using :q
  2. Nyissa meg a felfedezőt egy másik lapon a használatával, :Texploremajd lépjen ki a használatával:q
  3. Nyissa meg a fájlkezelőt az aktuális ablakban, majd töltse le az aktuális puffert, és törölje a pufferlistáról a :bdel(puffertörlés) gombbal.
MEGJEGYZÉS: A rövid parancs :Exsegítségével megnyithatja a fájlkezelőt is

Néha ugyanazokat a lépéseket kell ismételnem néhány soron, hogy szerkesszek valamit. Biztos vagyok benne, hogy a Vimnek lesz valami olyan funkciója, amely lehetővé teszi számomra ezt. Igazam van?

100% -ban igaz! Makrókról beszél, és a Vim támogatja a makrókat. Az utoljára végrehajtott parancs megismétlése egyszerű és egyszerű, ismétlődő feladatokat képes végrehajtani. Ha azonban a szövegfeldolgozás több lépésből áll az eredmény elérése érdekében, akkor a makrók jól jönnek.

Vegyünk egy példát a C fejlécfájlra:

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 word void and type int
  • Press Esc , move to the end of line using Shift+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 from a-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