Get started using the Vim text editor Sākt izmantot Spars teksta redaktors

by Sukrit Dhandhania on December 31, 2008 ar Sukrit Dhandhania 2008 December 31,

LinuxMacLogi

Vim is one of the most powerful and popular command line text editors around. Spars ir viens no spēcīgākajiem un tautas komandrindas teksta redaktoriem apkārt. It was initially only available for the Linux and UNIX platforms, but was then ported to Windows also. Sākotnēji bija pieejami tikai Linux un UNIX platformām, bet pēc tam arī Windows videi arī. The interface is clean and simple, and you use a combination of keys to perform tasks such as copy-paste, search and replace, delete a bunch of lines, and much more. Saskarne ir tīrs un vienkāršs, un jūs izmantot taustiņu kombināciju, lai veiktu tādus uzdevumus kā copy-paste, meklēt un aizstāt, izdzēst ķekars līniju, un vēl daudz vairāk.

Vim comes pre-installed with most distributions of Linux and on Mac OS. Spars nāk pre-installed ar lielāko daļu sadali Linux un Mac OS. In case you don't have it or want to install it on another platform you can get the installer from Ja jums nav, vai vēlaties instalēt to citā platformā var saņemt no uzstādītāja here šeit . . For Windows users you need to go Windows lietotājiem, jums jāiet here šeit and download the latest release of Vim. un lejupielādējiet jaunāko versiju no GNOME. Download the zip file for your version of Windows and extract it. Download zip fails jūsu Windows versiju un Extract to. Then run the installer. Tad palaidiet uzstādītājam. The only thing different between the Linux/Mac version of Vim and the Windows version is that the Windows version runs in its own graphical window. Vienīgais, kas atšķiras starp Linux / Mac versijā Spars un Windows versija, ka Windows versija darbojas savā grafisko logu. Let's take a closer look at its usage. Let's to tuvāk apskatīt tās lietošanu.

Before we get to the actual usage of Vim let me briefly explain to you the two modes that Vim runs in – command and insert mode. Pirms mēs to faktisko izmantošanu Spars ļaujiet man īsi paskaidrot jums diviem veidiem, kuri Spars trašu - vadības un ievietot režīmā. In the command mode you give instructions to Vim to take some action, such as delete a line, or search for a word. Ar komandu režīmā dot norādījumus Spars veikt kādu darbību, piemēram, dzēst līnijas, vai meklēt vārdu. When you are in the insert mode what you type goes in as text into the document you are editing. Kad esat ievietot režīmā, ko jūs tipa iet tik tekstu dokumentā jūs rediģēšanu. When you launch Vim you are in the command mode. Kad jūs uzsākt Spars atrodaties komandu režīmā. To switch to insert mode hit the 'i' key on your keyboard. , Lai pārslēgtos uz ievietotu mode hit "i" taustiņu uz tastatūras. You will see a notification at the bottom left of your screen like this: Jūs redzēsiet paziņojumu pie apakšējā kreisajā ekrāna šādi:

– INSERT – - INSERT --

This means you can now begin editing the file. Tas nozīmē, ka tagad jūs varat sākt rediģēt failu. To switch back to the command mode just hit the Escape key. Lai pārslēgtos atpakaļ uz komandu režīmu tieši skārusi Escape taustiņu. You will find that the “– INSERT –” notification at the bottom will disappear. Jūs redzēsiet, ka "- IERAKSTĪT -" paziņojums par grunts pazudīs. You are now in the command mode and can instruct Vim to delete a line, or to save the file, or whatever you may want to do with the document. Tu tagad komandu režīmā un var uzdot Spars izdzēst līniju, vai saglabāt failu, vai ko jūs varat darīt ar dokumentu.

To open an existing file or a to create a new one with Vim use the following syntax: Lai atvērtu esošu failu vai izveidot jaunu ar Spars lietot šādu sintaksi:

# vim helloworld.txt # Spars helloworld.txt

If you opened an existing file you should see its content, or a blank page if you created a new one. Ja esat atvēris esošo failu, jums vajadzētu redzēt tā saturu, vai tukšu lapu, ja esat izveidojis jaunu. Now before we proceed with using Vim, let's see how to exit Vim. Tagad, pirms mēs turpināt izmantot GNOME, redzēsim, kā iziet no GNOME. This is important because, unlike your standard graphical text editor, you cannot close the window to shut the application. Tas ir svarīgi, jo, atšķirībā no jūsu standarta grafiskā teksta redaktoru, jūs nevarat aizvērt logu izslēgt pieteikumu. To exit Vim and return to the command line you need to enter the following key combination: Lai izietu Spars un atgriezties komandrindas nepieciešams ievadīt šādu taustiņu kombinācija:

ESC :q ENTER ESC: q ENTER

In plain English the above command goes something like this, “Escape key, then a colon, followed immediately by a 'q', and then the Enter key to finish”. Vienkāršā angļu iepriekš minēto komandu iet kaut kas līdzīgs šim, "Escape taustiņu, tad kols, tūlīt pēc" Q "un pēc tam taustiņu Enter, lai pabeigtu. The “q” here stands for “quit”. "Q" šeit nozīmē "Quit". What Vim does here is that it exits without saving any changes you may have made to the file. Ko Spars tas šeit ir tāda, ka izejas, nesaglabājot izmaiņas, jums var būt veiktas failu. To save the file and quit add the 'w' or “write” option: Lai saglabātu failu un atmest pievienot "w" vai "rakstīt" iespēja:

ESC :wq ENTER ESC: WQ ENTER

You can also use the 'w' option without the 'q', if you just want to save the file while editing it and not quit Vim. Jūs varat arī izmantot "w" iespēja bez "q", ja jūs vienkārši vēlaties saglabāt failu rediģēšanas laikā, un ne atmest GNOME.

Now that we know how to get in an out of Vim let's see how to use it. Tagad mēs zinām, kā iekļūt no Spars redzēsim, kā to izmantot. Let's create a new document with Vim and begin writing: Let's izveidot jaunu dokumentu ar GNOME un sākt rakstiski:

# vim newdocument.txt # Spars newdocument.txt

Now hit 'i' on your keyboard to get into the insert mode. Tagad hit "i" uz tastatūras iekļūt ievietot režīmā. Write a few lines of text in the file. Uzrakstiet dažas rindiņas teksta failā. Once you are done hit the Escape key to go into the command mode, and then “:wq” to save and exit the file. Kad esat beidzis skārusi Escape taustiņu iedziļināties komandu režīmā un pēc tam "WQ" glābt un izejas failu. Now let's see if the file was written correctly. Tagad redzēsim, vai fails bija rakstīts pareizi. Windows users can open the document we created using Notepad. Windows lietotāji var atvērt dokumentu, mēs izveidojām izmantojot Notepad. If you are using Linux or a Mac run the following command to check out the contents of the file: Ja lietojat Linux vai Mac palaist šādu komandu izbraukšana no faila saturs:

# cat newdocument.txt # Cat newdocument.txt

You should see the contents of the file you just created. Jums vajadzētu redzēt no lietas materiāliem, kuru nupat izveidojāt saturu. Now open the same file using Vim and let's see what more Vim do do. Tagad ir atvērta pati failu ar GNOME un redzēsim, ko vēl Spars do darīt. Let's delete a few words and lines. Let's svītrot dažus vārdus un līnijas. While in command mode navigate you cursor to he beginning of a word and hit the key combination “dw” followed by Enter. Bet komanda režīmā vadīt Jūs kursoru viņš sākumā vārdu un nospiediet taustiņu kombināciju "DW", kam seko Enter. This should delete the word. Tam vajadzētu svītrot vārdu. Now let's delete a whole line. Tagad izdzēst visu līniju. Pick a line you want to delete and take the cursor to any location in that line and hit the key combination “dd” followed by Enter. Pick līnijas, kuru vēlaties izdzēst, un veikt kursoru uz jebkuru vietu Šajā rindā un nospiediet taustiņu kombināciju "dd", kam seko Enter. Line deleted. Line svītro.

Sometimes you make a mistake that you want to undo, say you want to bring back the line you just deleted. Dažreiz jūs veicat kļūda, ka jūs vēlaties atsaukt, ka vēlaties atvest līnija tikko svītro. To undo your last action go to the command mode and hit the key “u”. Lai atsauktu pēdējo darbību iet uz komandu režīmu un nospiediet taustiņu "u". You can continue hitting “u” to undo more changes. Jūs varat turpināt hitting "u" atsaukt citas izmaiņas.

These commands will get you started with Vim. Šīs komandas saņems sākāt ar GNOME. Practice what you learned here. Prakse, ko esat iemācījušies šeit. I will return with more cool stuff such as finding and replacing words, searching a text, and more. Es atpakaļ ar vairāk cool stuff, piemēram, atrast un aizstāt tekstu, meklēt tekstu un vairāk.

A quick recap of the commands you learned here: Ātri Atgādinājums komandām esat iemācījušies šeit:

1. 1. Save file – “:w” Saglabāt failu - "w"
2. 2. Quit file without saving – “:q” Atmest failu nesaglabājot - "q"
3. 3. Save and quit file – “:wq” Saglabāt un atmest failu - "WQ"
4. 4. Go into insert mode – “i” Iedziļināties ievietot veids - "i"
5. 5. Go into command mode – ESC Iedziļināties komandas veids - ESC
6. 6. Delete word – “dw” Svītrot vārdu - "DW"
7. 7. Delete line – “dd” Izdzēst līniju - "dd"
8. 8. Undo change – “u” Undo nemainās - "u"

Related Posts: Related Posts:
  • How to edit iPhoto images using another application Kā rediģēt iPhoto attēlus, izmantojot jaunu pieteikumu
  • How to use your Home folder as your Desktop in Ubuntu Kā lietot Home mapi darbvirsmā in Ubuntu
  • Overview: CoolMon 2 – a Windows system monitoring utility Pārskats: CoolMon 2 - Windows sistēmas uzraudzības lietderība
  • How to disable the balloon tips in Windows XP Kā atslēgt balons padomus Windows XP
  • How to display your system info on your Linux desktop Kā rādīt jūsu sistēmas informācija par jūsu Linux desktop
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Simple Palīdzība konsultācijas tāpat kā šo vienu savā e-pastā ik dienas - bez maksas! Just enter your email address below: Vienkārši ievadiet savu e-pasta adresi:

    You can always opt out of this email subscription at any time. Jūs vienmēr varat atteikties no šīs e-pasta abonementu jebkurā laikā.

    { 2 comments… read them below or (2 comments ... lasīt tos zem vai add one pievienot vienu } )

    1 1 James 12.31.08 at 12:04 pm At 12:04 12.31.08 James

    Come on ! Come on! Is there someone who still use vi (& its clones) ? Vai ir kāds, kas joprojām izmanto VI (un tās kloni)? There's hundred of editors out there who can ease much more the work for a writer…!!! Ir simtiem editors out there, kas var atvieglot daudz darba autors ...!

    Yeah, I know you can do more with Vi than any other editor, but believe me you still have to memorize a bunch of keyboard keys… Jā, es zinu, jūs varat darīt vairāk ar Vi nekā jebkurš cits redaktors, bet ticiet man jums vēl ir iegaumēt ķekars klaviatūras taustiņiem ...

    2 2 lamberto 03.29.09 at 9:19 am at 9:19 03.29.09 Lamberto am

    compliments for a very useful start, but i'm unable to find the rest of the tutorial? komplimentus par ļoti noderīgu sākums, bet es esmu nespēj atrast pārējo pamācību?
    lam LAM

    Leave a Comment Leave Comment

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Jūs varat izmantot šos HTML tagus un atribūtus: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>