0 valutazioniIl 0% ha trovato utile questo documento (0 voti)
40 visualizzazioni52 pagine
Multi-level undo / redo - all editing actions are recorded from the opening of a file. - unlimited undo and redo buffers. $pell checker - around 100000 words were added in the dictionary. - users can register new words in their own dictionary.
Multi-level undo / redo - all editing actions are recorded from the opening of a file. - unlimited undo and redo buffers. $pell checker - around 100000 words were added in the dictionary. - users can register new words in their own dictionary.
Copyright:
Attribution Non-Commercial (BY-NC)
Formati disponibili
Scarica in formato DOCX, PDF, TXT o leggi online su Scribd
Multi-level undo / redo - all editing actions are recorded from the opening of a file. - unlimited undo and redo buffers. $pell checker - around 100000 words were added in the dictionary. - users can register new words in their own dictionary.
Copyright:
Attribution Non-Commercial (BY-NC)
Formati disponibili
Scarica in formato DOCX, PDF, TXT o leggi online su Scribd
- switch between documents using file selection tab. - Ctrl+Tab brings the last accessed document to topmost. - support window splitter to see different parts of a document.
$ntax highlighting - configurable via custom syntax files. - preconfigured for more than 100 computer languages.
Multi-level undo / redo - all editing actions are recorded from the opening of a file. - any document always can be undone to it's initial contents. - unlimited undo and redo buffers.
Project management - manage group of related files into one project. - remote files also can be included in a project.
Director tree view window - click to open documents. - filter to display only selected file class.
Find & Replace - replace specified text one by one, or as a whole. - support regular expression.
Column mode editing - copy and paste rectangular selections. - switch between column mode and line mode. (Alt+C)
Natural word wrapping - word wrapping does not affect syntax highlighting. - configurable wrapping indentation. (easer to understand the syntax)
$pell checker - around 100000 words were added in the dictionary. - users can register new words in their own dictionary. (InstallDiruser.dic)
&ser tools and macros - execute external programs with proper arguments. - compile, execute and test your code. - ease your fingers with key stroke recording. (record & replay)
Edit remote files directl using built-in FTP client - open, edit, and save documents in remote FTP servers. - save account information (encoded) for automatic logon.
Print & Print preview - configurable page header and footer. - print with line numbers. - print with syntax highlighting. (used in color printer) - true type font selection for printer.
Other useful features support Unicode & UTF-8 encoding, drag & drop text editing, single instance multiple instances, ability to detect changed files, bookmark & go to, highlight active line, highlight matching pairs, multi-byte support with integrated IME (for eastern languages), auto indent, wheel mouse support, copy & paste, line numbers, configurable line spacing, option to save files in Unix format,
http://fprintf.net/vimCheatSheet.html Vim - Introduction Short Ior Vi IMproved. An enhanced vi clone (which is not Iully compatible with the original UNIX vi) Developed by Bram Moolenaar and others. It is open source (and GPL-compatible since version 6.1.) Serves as charityware Ior ICCF Holland
Where, When and Why to use Vim - Where Vim is indeed a very portable editor - runs on most UNIX Ilavours as well as: Windows MacOS DOS VMS and many others OSes. Several Iront-ends exist: console Gtk MotiI KDE Windows GUI Many Others: Check http://www.vim.org/6kbyte.php . Previous , Index , Next
Normal Mode and Editing Mode By deIault Vim starts in the so called normal mode - one cannot enter text then. To begin entering text type one oI the Iollowing commands: "i" or Insert~ - to insert text beIore the cursor. "a" - to append text aIter the cursor. (useIul at the end oI the lines.) "I" - insert text beIore Iirst character in the line. "A" - append aIter last char in the line. To switch back into normal mode, press the Esc~ key. Using :source $VMRUNTME/mswin.vim will make the insert mode more Windows-like and Iunctional. Note: II you do not know what is $VIMRUNTIME - Iind it using: :echo $VMRUNTME Hard core vi users avoid it. Shlomi Fish Uses it.
Normal Mode: In normal mode one can use the regular qwerty-keys to perIorm common commands: Move around Cut or copy text to the registers Manipulate text programmatically Command-line mode: ":" Once ":" is pressed in normal mode, one can enter the so-called "ex" commands at the command-line. This allows saving the Iile "w", quitting "q" or "q!", substituting text "s///", etc. Some oI these commands will be covered in more detail later on.
Moving around Vim (and vi in general) has many commands Ior moving around. A complete listing oI them can be Iound in :help motion.txt. Examples: h/<Left>/<Backspace>/CTRL-H - LeIt l/<Right>/<Space> - Right k/<Up>/CTRL-P - Up j/<Down>/CTRL-J/CTRL-N - Down 0 - To the beginning oI the line $ - To the end oI the line ^ - To the Iirst non-blank character in the line % - To a matching parens (a Iavourite oI mine) gg - To the beginning oI the Iile G - To the end oI the Iile (/) - previous/next sentence {/} - previous/next paragraphs Some oI these commands can be preceded by a number which repeat them several times. For instance 5h moves 5 character to the leIt And 100gg moves to line number 100.
Demo 2: First Code Demo Moving Iast and easy : gg, % Finding error by line number: set nu , :24 Finding word highlight: /, ? !ctags :%s/XXX/YYY/g :%s/XXX/YYY/c :3,5s/XXX/YYY/g :%s/^$//g (removing empty lines) /REGEXP
Parameterised Movements: /[Regexp] - Go to the next occurence oI the (Vim) regular expression |Regexp| ?[Regexp] - Previous occurence oI regexp. Use n and N to move to the next or previous matches. f[Char] - the next occurence oI [Char] on the current line. F[Char] - previous occurence t[Char] - one character beIore the next occurence T[Char] - previous one character.
Ranges In Vim, one can execute several commands on ranges (:help range). Ranges are: [Start],[End] Or alternatively % Ior the entire Iile. Or an empty range-speciIier Ior context-speciIic deIault (such as the current line or the entire Iile) [Start] and [End] can be: [Digits] - an absolute line number . - the current line $ - last line in a Iile. 't or 'T - the position oI mark t. /{pattern}[/] - next line where matches. ?{pattern[?] - previous line \/ - the next line where the previously used search pattern matches. \? - the previous line For example iI you've set marks "a" and "e", then you can say: :'a,'es/^/# / To comment out the text.
Auto-completion :help compl-generic CtrlP Iinds a previous match Ior a word that was started to be inputted in the Iile. Press it more times Ior more alternatives. CtrlN is the same Ior words aIter the cursor. This allows entering long identiIiers in code, etc. more quickly.
Registers A yank (copy) or delete (cut) can copy the text into a speciIied register. A register is speciIied with a double-quotes (") Iollowed by the register name which precedes the y or d command. There are several registers available: The deIault, unnamed register "" Standard named register "A-"Z or "a-"z (case insensitive) The clipboard register "+. (available in GUI Vims, and deIaults to the unnamed register on console Vims) Registers 1-9 which provide history oI the copied texts. Other special registers. (check :help registers) To paste a text Irom a register use the "{reg}p command. Examples "sy$ - yanks the text until the end oI the line into register 's'. gg"+yG - copies the entire Iile to the clipboard.
Seven habits of effective text editing Bram Moolenaar November 2000 I you spend u IoL oI LIme LypIng pIuIn LexL, wrILIng progrums or HTM, you cun suve mucI oI LIuL LIme by usIng u good edILor und usIng IL eIIecLIveIy. TIIs puper wIII presenL guIdeIInes und IInLs Ior doIng your work more quIckIy und wILI Iewer mIsLukes. TIe open source LexL edILor VIm (VI Mproved) wIII be used Iere Lo presenL LIe Ideus ubouL eIIecLIve edILIng, buL LIey uppIy Lo oLIer edILors jusL us weII. CIoosIng LIe rIgIL edILor Is ucLuuIIy LIe IIrsL sLep Lowurds eIIecLIve edILIng. TIe dIscussIon ubouL wIIcI edILor Is LIe besL Ior you wouId Luke Loo mucI room und Is uvoIded. I you don'L know wIIcI edILor Lo use or ure dIssuLIsIIed wILI wIuL you ure currenLIy usIng, gIve VIm u Lry; you won'L be dIsuppoInLed. |VIm communds und opLIons ure prInLed In 1h1s !on1| Part 1: edit a file 1. Move uroond qoickly MosL LIme Is spenL reudIng, cIeckIng Ior errors und IookIng Ior LIe rIgIL pIuce Lo work on, ruLIer LIun InserLIng new LexL or cIungIng IL. NuvIguLIng LIrougI LIe LexL Is done very oILen, LIus you sIouId Ieurn Iow Lo do LIuL quIckIy. QuILe oILen you wIII wunL Lo seurcI Ior some LexL you know Is LIere. Or Iook uL uII IInes wIere u cerLuIn word or pIruse Is used. You couId sImpIy use LIe seurcI commund 5,11cn Lo IInd LIe LexL, buL LIere ure smurLer wuys: I you see u specIIIc word und wunL Lo seurcI Ior oLIer occurrences oI LIe sume word, use LIe commund. L wIII grub LIe word Irom under LIe cursor und seurcI Ior LIe nexL one. I you seL LIe '1ncsc,ch' opLIon, VIm wIII sIow LIe IIrsL muLcI Ior LIe puLLern, wIIIe you ure sLIII LypIng IL. TIIs quIckIy sIows u Lypo In LIe puLLern. I you seL LIe 'h1sc,ch' opLIon, VIm wIII IIgIIIgIL uII muLcIes Ior LIe puLLern wILI u yeIIow buckground. TIIs gIves u quIck overvIew oI wIere LIe seurcI commund wIII Luke you. n progrum code IL cun sIow wIere u vurIubIe Is used. You don'L even Iuve Lo move LIe cursor Lo see LIe muLcIes. n sLrucLured LexL LIere ure even more possIbIIILIes Lo move uround quIckIy. VIm Ius specIIIc communds Ior progrums In C (und sImIIur Iunguuges IIke C++ und Juvu): Use Lo jump Irom un open bruce Lo ILs muLcIIng cIosIng bruce. Or Irom u "#II" Lo LIe muLcIIng "#endII". AcLuuIIy, cun jump Lo muny dIIIerenL muLcIIng ILems. L Is very useIuI Lo cIeck II () und {] consLrucLs ure buIunced properIy. Use Lo jump buck Lo LIe "{" uL LIe sLurL oI LIe currenL code bIock. Use / Lo jump Irom LIe use oI u vurIubIe Lo ILs IocuI decIuruLIon. TIere ure muny more, oI course. TIe poInL Is LIuL you need Lo geL Lo know LIese communds. You mIgIL objecL LIuL you cun'L possIbIy Ieurn uII LIese communds - LIere ure Iundreds oI dIIIerenL movemenL communds, some sImpIe, some very cIever - und IL wouId Luke weeks oI LruInIng Lo Ieurn LIem uII. WeII, you don'L need Lo; InsLeud reuIIze wIuL your specIIIc wuy oI edILIng Is, und Ieurn onIy LIose communds LIuL muke your edILIng more eIIecLIve. TIere ure 9ree busic s9eps: WIIIe you ure edILIng, keep un eye ouL Ior ucLIons you repeuL undJor spend quILe u bIL oI LIme on. Ind ouL II LIere Is un edILor commund LIuL wIII do LIIs ucLIon quIcker. Reud LIe documenLuLIon, usk u IrIend, or Iook uL Iow oLIers do LIIs. TruIn usIng LIe commund. Do LIIs unLII your IIngers Lype IL wILIouL LIInkIng. eL's use un exumpIe Lo sIow Iow IL works: You IInd LIuL wIen you ure edILIng C progrum IIIes, you oILen spend LIme IookIng Ior wIere u IuncLIon Is deIIned. You currenLIy use LIe commund Lo seurcI Ior oLIer pIuces wIere LIe IuncLIon nume uppeurs, buL end up goIng LIrougI u IoL oI muLcIes Ior wIere LIe IuncLIon Is used InsLeud oI deIIned. You geL LIe Ideu LIuL LIere musL be u wuy Lo do LIIs IusLer. ookIng LIrougI LIe quIck reIerence you IInd u remurk ubouL jumpIng Lo Lugs. TIe documenLuLIon sIows Iow LIIs cun be used Lo jump Lo u IuncLIon deIInILIon, jusL wIuL you were IookIng Ior! You experImenL u bIL wILI generuLIng u Lugs IIIe, usIng LIe cLugs progrum LIuL comes wILI VIm. You Ieurn Lo use LIe %#( commund, und IInd you suve IoLs oI LIme usIng IL. To muke IL eusIer, you udd u Iew IInes Lo your MukeIIIe Lo uuLomuLIcuIIy generuLe LIe Lugs IIIe. A coupIe oI LIIngs Lo wuLcI ouL Ior wIen you ure usIng LIese LIree sLeps: " wunL Lo geL LIe work done, don'L Iuve LIme Lo Iook LIrougI LIe documenLuLIon Lo IInd some new commund". I you LIInk IIke LIIs, you wIII geL sLuck In LIe sLone uge oI compuLIng. Some peopIe use NoLepud Ior everyLIIng, und LIen wonder wIy oLIer peopIe geL LIeIr work done In IuII LIe LIme... Don'L overdo IL. I you uIwuys Lry Lo IInd LIe perIecL commund Ior every IILLIe LIIng you do, your mInd wIII Iuve no LIme IeIL Lo LIInk ubouL LIe work you were ucLuuIIy doIng. JusL pIck ouL LIose ucLIons LIuL Luke more LIme LIun necessury, und LruIn LIe communds unLII you don'L need Lo LIInk ubouL IL wIen usIng LIem. TIen you cun concenLruLe on LIe LexL. n LIe IoIIowIng secLIons LIere wIII be suggesLIons Ior ucLIons LIuL mosL peopIe Iuve Lo deuI wILI. You cun use LIese us InspIruLIon Ior usIng LIe 9ree busic s9eps Ior your own work. . on'9 9ype i9 9ice TIere Is u IImILed seL oI words we Lype. And even u IImILed number oI pIruses und senLences. EspecIuIIy In compuLer progrums. ObvIousIy, you don'L wunL Lo Lype LIe sume LIIng LwIce. Very oILen you wIII wunL Lo cIunge one word InLo unoLIer. I LIIs Is Lo be done In LIe wIoIe IIIe, you cun use LIe s (subsLILuLe) commund. I onIy u Iew IocuLIons needs cIungIng, u quIck meLIod Is Lo use LIe commund Lo IInd LIe nexL occurrence oI LIe word und use cW Lo cIunge LIe word. TIen Lype n Lo IInd LIe nexL word und . (doL) Lo repeuL LIe cW commund. TIe . commund repeuLs LIe IusL cIunge. A cIunge, In LIIs conLexL, Is InserLIng, deIeLIng or repIucIng LexL. BeIng ubIe Lo repeuL LIIs Is u very powerIuI mecIunIsm. I you orgunIse your edILIng uround IL, muny cIunges wIII become u muLLer oI IILLIng jusL LIuL . key. WuLcI ouL Ior mukIng oLIer cIunges In beLween, becuuse IL wIII repIuce LIe cIunge LIuL you were repeuLIng. nsLeud you mIgIL wunL Lo murk LIe IocuLIon wILI LIe m commund, conLInue your repeuLed cIunge und come buck LIere IuLer. Some IuncLIon und vurIubIe numes cun be uwkwurd Lo Lype. Cun you quIckIy Lype "XpmCreuLePIxmupromDuLu" wILIouL u Lypo und wILIouL IookIng IL up? VIm Ius u compIeLIon mecIunIsm LIuL mukes LIIs u wIoIe IoL eusIer. L Iooks up words In LIe IIIe you ure edILIng, und uIso In #IncIude'd IIIes. You cun Lype "XpmCr", LIen IIL %# und VIm wIII expund IL Lo "XpmCreuLePIxmupromDuLu" Ior you. NoL onIy does LIIs suve quILe u bIL oI LypIng, IL uIso uvoIds mukIng u Lypo und IuvIng Lo IIx IL IuLer wIen LIe compIIer gIves you un error messuge. WIen you ure LypIng u pIruse or senLence muILIpIe LImes, LIere Is un even quIcker upproucI. VIm Ius u mecIunIsm Lo record u mucro. You Lype 6, Lo sLurL recordIng InLo regIsLer 'u'. TIen you Lype your communds us usuuI und IInuIIy IIL 6 uguIn Lo sLop recordIng. WIen you wunL Lo repeuL LIe recorded communds you Lype ,. TIere ure z6 regIsLers uvuIIubIe Ior LIIs. WILI recordIng you cun repeuL muny dIIIerenL ucLIons, noL jusL InserLIng LexL. Keep LIIs Is mInd wIen you know you ure goIng Lo repeuL someLIIng. One LIIng Lo wuLcI ouL Ior wIen recordIng Is LIuL LIe communds wIII be pIuyed buck exucLIy us you Lyped LIem. WIen movIng uround you musL keep In mInd LIuL LIe LexL you move over mIgIL be dIIIerenL wIen LIe commund Is repeuLed. MovIng Iour cIurucLers IeIL mIgIL work Ior LIe LexL wIere you ure recordIng, buL IL mIgIL need Lo be IIve cIurucLers wIere you repeuL LIe communds. L's oILen necessury Lo use communds Lo move over LexL objecLs (words, senLences) or move Lo u specIIIc cIurucLer. WIen LIe communds you need Lo repeuL ure geLLIng more compIIcuLed, LypIng LIem rIgIL uL once Is geLLIng more dIIIIcuIL. nsLeud oI recordIng LIem, you sIouId LIen wrILe u scrIpL or mucro. TIIs Is very useIuI Lo muke LempIuLes Ior purLs oI your code; Ior exumpIe, u IuncLIon Ieuder. You cun muke LIIs us cIever us you IIke. . Iix i9 en i9's rong L's normuI Lo muke errors wIIIe LypIng. Nobody cun uvoId IL. TIe LrIck Is Lo quIckIy spoL und correcL LIem. TIe edILor sIouId be ubIe Lo IeIp you wILI LIIs. BuL you need Lo LeII IL wIuL's wrong und wIuL's rIgIL. Very oILen you wIII muke LIe sume mIsLuke uguIn und uguIn. Your IIngers jusL don'L do wIuL you InLended. TIIs cun be correcLed wILI ubbrevIuLIons. A Iew exumpIes: ,-- :n1x 1n:x ,-- ,ccoss ,coss ,-- h1c 1hc The words will be automatically corrected just aIter you typed them. TIe sume mecIunIsm cun be used Lo Lype u Iong word wILI jusL u Iew cIurucLers. EspecIuIIy useIuI Ior words LIuL you IInd Iurd Lo Lype, und IL uvoIds LIuL you Lype LIem wrong. ExumpIes: ,-- 5n 5cn:1n ,-- hS h,n/,c So!1W,c However, LIese Lend Lo expund Lo LIe IuII word wIen you don'L wunL IL, wIIcI mukes IL dIIIIcuIL wIen you reuIIy wunL Lo InserL "MS" In your LexL. L Is besL Lo use sIorL words LIuL don'L Iuve u meunIng oI LIeIr own. To IInd errors In your LexL VIm Ius u cIever IIgIIIgILIng mecIunIsm. TIIs wus ucLuuIIy meunL Lo be used Lo do synLux IIgIIIgILIng oI progrums, buL IL cun cuLcI und IIgIIIgIL errors us weII. SynLux IIgIIIgILIng sIows commenLs In coIour. TIuL doesn'L sound IIke un ImporLunL IeuLure, buL once you sLurL usIng IL you wIII IInd LIuL IL IeIps u IoL. You cun quIckIy spoL LexL LIuL sIouId be u commenL, buL Isn'L IIgIIIgILed us sucI (you probubIy IorgoL u commenL murker).Or see u IIne oI code IIgIIIgILed us commenL (you IorgoL Lo InserL u "J"). TIese ure errors wIIcI ure Iurd Lo spoL In u B&W IIIe und cun wusLe u IoL oI LIme wIen LryIng Lo debug LIe code. TIe synLux IIgIIIgILIng cun uIso cuLcI unbuIunced bruces. An unbuIunced ")" Is IIgIIIgILed wILI u brIgIL red buckground. You cun use LIe commund Lo see Iow LIey muLcI, und InserL u "(" or ")" uL LIe rIgIL posILIon. OLIer common mIsLukes ure uIso quIckIy spoLLed, Ior exumpIe usIng "#IncIuded <sLdIo.I>" InsLeud oI "#IncIude <sLdIo.I>". You eusIIy mIss LIe mIsLuke In B&W, buL quIckIy spoL LIuL "IncIude" Is IIgIIIgILed wIIIe "IncIuded" Isn'L. A more compIex exumpIe: Ior EngIIsI LexL LIere Is u Iong IIsL oI uII words LIuL ure used. Any word noL In LIIs IIsL couId be un error. WILI u synLux IIIe you cun IIgIIIgIL uII words LIuL ure noL In LIe IIsL. WILI u Iew exLru mucros you cun udd words Lo LIe wordIIsL, so LIuL LIey ure no Ionger IIugged us un error. TIIs works jusL us you wouId expecL In u word processor. n VIm IL Is ImpIemenLed wILI scrIpLs und you cun IurLIer Lune IL Ior your own use: Ior exumpIe, Lo onIy cIeck LIe commenLs In u progrum Ior speIIIng errors. Part 2: edit more files q. A Iile seldom comes ulone PeopIe don'L work on jusL one IIIe. MosLIy LIere ure muny reIuLed IIIes, und you edIL severuI uILer eucI oLIer, or even severuI uL LIe sume LIme. You sIouId be ubIe Lo Luke udvunLuge oI your edILor Lo muke workIng wILI severuI IIIes more eIIIcIenL. TIe prevIousIy menLIoned Lug mecIunIsm uIso works Ior jumpIng beLween IIIes. TIe usuuI upproucI Is Lo generuLe u Lugs IIIe Ior LIe wIoIe projecL you ure workIng on. You cun LIen quIckIy jump beLween uII IIIes In LIe projecL Lo IInd LIe deIInILIons oI IuncLIons, sLrucLures, LypedeIs, eLc. TIe LIme you suve compured wILI munuuIIy seurcIIng Is Lremendous; creuLIng u Lugs IIIe Is LIe IIrsL LIIng do wIen browsIng u progrum. AnoLIer powerIuI mecIunIsm Is Lo IInd uII occurrences oI u nume In u group oI IIIes, usIng LIe c5 commund. VIm mukes u IIsL oI uII muLcIes, und jumps Lo LIe IIrsL one. TIe cn commund Lukes you Lo eucI nexL muLcI. TIIs Is very useIuI II you need Lo cIunge LIe number oI urgumenLs In u IuncLIon cuII. ncIude IIIes conLuIn useIuI InIormuLIon. BuL IIndIng LIe one LIuL conLuIns LIe decIuruLIon you need Lo see cun Luke u IoL oI LIme. VIm knows ubouL IncIude IIIes, und cun seurcI LIem Ior u word you ure IookIng Ior. TIe mosL common ucLIon Is Lo Iookup LIe proLoLype oI u IuncLIon. PosILIon LIe cursor on LIe nume oI LIe IuncLIon In your IIIe und Lype : VIm wIII sIow u IIsL oI uII muLcIes Ior LIe IuncLIon nume In IncIuded IIIes. I you need Lo see more conLexL, you cun dIrecLIy jump Lo LIe decIuruLIon. A sImIIur commund cun be used Lo cIeck II you dId IncIude LIe rIgIL Ieuder IIIes. n VIm you cun spIIL LIe LexL ureu In severuI purLs Lo edIL dIIIerenL IIIes. TIen you cun compure LIe conLenLs oI Lwo or more IIIes und copyJpusLe LexL beLween LIem. TIere ure muny communds Lo open und cIose wIndows, jump beLween LIem, LemporurIIy IIde IIIes, eLc. AguIn you wIII Iuve Lo use LIe LIree busIc sLeps Lo seIecL LIe seL oI communds you wunL Lo Ieurn Lo use. TIere ure more uses oI muILIpIe wIndows. TIe prevIew-Lug mecIunIsm Is u very good exumpIe. TIIs opens u specIuI prevIew wIndow, wIIIe keepIng LIe cursor In LIe IIIe you ure workIng on. TIe LexL In LIe prevIew wIndow sIows, Ior exumpIe, LIe IuncLIon decIuruLIon Ior LIe IuncLIon nume LIuL Is under LIe cursor. I you move LIe cursor Lo unoLIer nume und Ieuve IL LIere Ior u second, LIe prevIew wIndow wIII sIow LIe deIInILIon oI LIuL nume. L couId uIso be LIe nume oI u sLrucLure or u IuncLIon wIIcI Is decIured In un IncIude IIIe oI your projecL. g. Le9's ork 9oge9er An edILor Is Ior edILIng LexL. An e-muII progrum Is Ior sendIng und receIvIng messuges. An OperuLIng SysLem Is Ior runnIng progrums. EucI progrum Ius ILs own Lusk und sIouId be good uL IL. TIe power comes Irom IuvIng LIe progrums work LogeLIer. A sImpIe exumpIe: SeIecL some sLrucLured LexL In u IIsL und sorL IL: so1. TIe exLernuI "sorL" commund Is used Lo IIILer LIe LexL. Eusy, Isn'L IL? TIe sorLIng IuncLIonuIILy couId be IncIuded In LIe edILor. BuL Iuve u Iook uL "mun sorL", IL Ius u IoL oI opLIons. And IL's probubIy u nIILy uIgorILIm LIuL does LIe sorLIng. Do you wunL Lo IncIude uII LIuL In un edILor? AIso Ior oLIer IIILer communds? L wouId grow Iuge. L Ius uIwuys been LIe spIrIL oI UnIx Lo Iuve sepuruLe progrums LIuL do LIeIr job weII, und work LogeLIer Lo perIorm u bIgger Lusk. UnIorLunuLeIy, mosL edILors don'L work Loo weII LogeLIer wILI oLIer progrums - you cun'L repIuce LIe e-muII edILor In NeLscupe wILI unoLIer one, Ior exumpIe. You end up usIng u crIppIed edILor. AnoLIer Lendency Is Lo IncIude uII kInds oI IuncLIonuIILy InsIde LIe edILor; Emucs Is u good exumpIe oI wIere LIIs cun end up. (Some cuII IL un operuLIng sysLem LIuL cun uIso be used Lo edIL LexL.) VIm LrIes Lo InLegruLe wILI oLIer progrums, buL LIIs Is sLIII u sLruggIe. CurrenLIy IL's possIbIe Lo use VIm us LIe edILor In MS-DeveIoper SLudIo und SnIII. Some e-muII progrums LIuL supporL un exLernuI edILor, IIke MuLL, cun use VIm. nLegruLIon wILI Sun WorksIop Is beIng worked on. GeneruIIy LIIs Is un ureu LIuL Ius Lo be Improved In LIe neur IuLure. OnIy LIen wIII we geL u sysLem LIuL's beLLer LIun LIe sum oI ILs purLs. 6. Tex9 is s9roc9ored You wIII oILen work wILI LexL LIuL Ius some kInd oI sLrucLure, buL dIIIerenL Irom wIuL Is supporLed by LIe uvuIIubIe communds. TIen you wIII Iuve Lo IuII buck Lo LIe "buIIdIng bIocks" oI LIe edILor und creuLe your own mucros und scrIpLs Lo work wILI LIIs LexL. We ure geLLIng Lo LIe more compIIcuLed sLuII Iere. One oI LIe sImpIer LIIngs Is Lo speed up LIe edIL-compIIe-IIx cycIe. VIm Ius LIe m,c commund, wIIcI sLurLs your compIIuLIon, cuLcIes LIe errors IL produces und IeLs you jump Lo LIe error IocuLIons Lo IIx LIe probIems. I you use u dIIIerenL compIIer, LIe error messuges wIII noL be recognIsed. nsLeud oI goIng buck Lo LIe oId "wrILe IL down" sysLem, you sIouId udjusL LIe 'co!om,1' opLIon. TIIs LeIIs VIm wIuL your errors Iook IIke und Iow Lo geL LIe IIIe nume und IIne number ouL oI LIem. L works Ior LIe compIIcuLed gcc error messuges, LIus you sIouId be ubIe Lo muke IL work Ior uImosL uny compIIer. SomeLImes udjusLIng Lo u Lype oI IIIe Is jusL u muLLer oI seLLIng u Iew opLIons or wrILIng u Iew mucros. or exumpIe, Lo jump uround munuuI puges, you cun wrILe u mucro LIuL grubs LIe word under LIe cursor, cIeurs LIe buIIer und LIen reuds LIe munuuI puge Ior LIuL word InLo LIe buIIer. TIuL's u sImpIe und eIIIcIenL wuy Lo Iookup cross-reIerences. UsIng LIe LIree busIc sLeps, you cun work more eIIecLIveIy wILI uny sorL oI sLrucLured IIIe. JusL LIInk ubouL LIe ucLIons you wunL Lo do wILI LIe IIIe, IInd LIe edILor communds LIuL do IL und sLurL usIng LIem. L's reuIIy us sImpIe us IL sounds. You jusL Iuve Lo do IL. Part 3: sharpen the saw ,. Muke i9 u ubi9 eurnIng Lo drIve u cur Lukes eIIorL. s LIuL u reuson Lo keep drIvIng your bIcycIe? No, you reuIIze you need Lo InvesL LIme Lo Ieurn u skIII. TexL edILIng Isn'L dIIIerenL. You need Lo Ieurn new communds und Lurn LIem InLo u IubIL. On LIe oLIer Iund, you sIouId noL Lry Lo Ieurn every commund un edILor oIIers. TIuL wouId be u compIeLe wusLe oI LIme. MosL peopIe onIy need Lo Ieurn 1o Lo zo percenL oI LIe communds Ior LIeIr work. BuL IL's u dIIIerenL seL oI communds Ior everybody. L requIres LIuL you Ieun buck now und LIen, und wonder II LIere Is some repeLILIve Lusk LIuL couId be uuLomuLed. I you do u Lusk onIy once, und don'L expecL IuvIng Lo do IL uguIn, don'L Lry Lo opLImIse IL. BuL you probubIy reuIIze you Iuve been repeuLIng someLIIng severuI LImes In LIe IusL Iour. TIen seurcI LIe documenLuLIon Ior u commund LIuL cun do IL quIcker. Or wrILe u mucro Lo do IL. WIen IL's u Iurger Lusk, IIke IInIng ouL u specIIIc sorL oI LexL, you couId Iook uround In newsgroups or on LIe nLerneL Lo see II somebody uIreudy soIved IL Ior you. TIe essenLIuI busIc sLep Is LIe IusL one. You cun LIInk oI u repeLILIve Lusk, IInd u nIce soIuLIon Ior IL und uILer LIe weekend you IorgoL Iow you dId IL. TIuL doesn'L work. You wIII Iuve Lo repeuL LIe soIuLIon unLII your IIngers do IL uuLomuLIcuIIy. OnIy LIen wIII you reucI LIe eIIIcIency you need. Don'L Lry Lo Ieurn Loo muny LIIngs uL once. BuL doIng u Iew uL LIe sume LIme wIII work weII. or LrIcks you don'L use oILen enougI Lo geL LIem In your IIngers, you mIgIL wunL Lo wrILe LIem down Lo be ubIe Lo Iook LIem up IuLer. Anywuy, II you keep LIe gouI In vIew, you wIII IInd wuys Lo muke your edILIng more und more eIIecLIve. One IusL remurk Lo remInd you oI wIuL Iuppens wIen peopIe Ignore uII LIe ubove: sLIII see peopIe wIo spend IuII LIeIr duy beIInd u VDU IookIng up uL LIeIr screen, LIen down uL Lwo IIngers, LIen up uL LIe screen, eLc. - und LIen wonder wIy LIey geL so LIred... Type wILI Len IIngers! L's noL jusL IusLer, IL uIso Is mucI Iess LIresome. UsIng u compuLer progrum Ior one Iour eucI duy, IL onIy Lukes u coupIe oI weeks Lo Ieurn Lo LoucI-Lype. Epilogue TIe Ideu Ior LIe LILIe comes Irom LIe successIuI book "TIe ; IubILs oI IIgIIy eIIecLIve peopIe" by SLepIen R. Covey. recommend IL Lo everyone wIo wunLs Lo soIve personuI und proIessIonuI probIems (und wIo doesn'L?). AILIougI some oI you wIII cIuIm IL cume Irom LIe DIIberL book "Seven yeurs oI IIgIIy deIecLIve peopIe" by ScoLL Adums (uIso recommended!). See ILLp:JJIccI-IoIIund.orgJcIIck1.ILmI und go Lo "recommended books und CDs". About the author Brum MooIenuur Is LIe muIn uuLIor oI VIm. He wrILes LIe core VIm IuncLIonuIILy und seIecLs wIuL code submILLed by muny oLIers Is IncIuded. He gruduuLed uL LIe LecInIcuI unIversILy oI DeIIL us u compuLer LecInIcIun. Now Ie muInIy works on soILwure, buL sLIII knows Iow Lo IundIe u soIderIng Iron. He Is Iounder und Lreusurer oI CC HoIIund, wIIcI IeIps orpIuns In Ugundu. He does IreeIunce work us u sysLems urcIILecL, buL ucLuuIIy spends mosL LIme workIng on VIm. HIs e-muII uddress: Brum AT MooIenuur.neL.
Vim In9rodoc9ion und To9oriul
oILen LrIed Lo Ieurn LIe greuL Emucs edILorJDEJoperuLIng sysLem. TIe IusL LIme LrIed IL, spenL some LIme geLLIng comIorLubIe wILI IL unLII wunLed Lo cusLomIze my .emacs IIIe. TIuL wus LIe poInL wIen enLered vi .emacs. As soon us reuIIzed wIuL `ve done, knew LIuL VIm Ius won me over u Iong LIme ugo. So, Iere um - usIng VIm us my edILor1 oI cIoIce. AnoLIer bIg moLIvuLIonuI boosL cume uILer dIscovered LIuL my preIerred sIeII (ZSH) Ius un uwesome vI-mode IncIudIng LIe commund mode (yes, you cun swILcI beLween commund und InserL mode!). VIm Ius u greuL deuI oI IeuLures, und IeurnIng LIem Lukes some LIme. OI course LIere ure muny onIIne-LuLorIuIs und LIps`n`LrIcks puges, buL LIe IeIp-IIIes ure very good Loo! TIere ure overvIew-puges, summury puges und some commenLs uL LIe communds. Look LIe upproucI Lo sLurL usIng some LuLorIuI und IeL LIe IeIp-sysLem guIde (Lype :help <command> Lo geL IeIp Ior LIe commund) me LIrougI LIe resL. IIke Lo Lry LIe communds In u LesL-IIIe, und Luke u sIorL noLe oI ImporLunL communds. AnoLIer reuson IIke Lo use VIm Is becuuse IL`s mucI more IeuILIy LIun Emucs (usIng LIe deIuuIL-keymuppIngs). HeuILIy? Muny communds ure eusIIy Lyped wILI u sIngIe keysLroke - LIe vIrLue oI u moduI edILor, InsLeud oI Iong commund-cIuIns wILI IoLs oI modIIIer keys. Even II you Iuve u nuLuruI keybourd, pressIng CLrI, AIL eLc Is cerLuInIy noL nuLuruI uL uII. JusL remember: VIm`s busIcs ure reuIIy very sImpIe, buL In combInuLIon LIe sImpIe communds become very powerIuI. Modes You Iuve modes: Commund mode: uII keysLrokes ure InLerpreLed us communds nserL mode: mosL keysLrokes ure InserLed us LexL (IeuvIng ouL LIose wILIlmodIIIer keys) VIsuuI mode: IeIps Lo vIsuuIIy seIecL some LexL, muy be seen us u submode oIlLIe LIe commund mode.
To swILcI Irom LIe InserL or vIsuuI mode Lo LIe commund mode, Lype <Esc>. To swILcI Irom LIe commund mode Lo LIe InserL mode Lype one oI i .swILcI Lo InserL mode beIore LIe currenL posILIon a .swILcI Lo InserL mode uILer LIe currenL posILIon (uppend) .jump Lo LIe IIrsL non-bIunk cIurucLer In LIe currenL IIne und swILcIlLo LIe InserL mode A .jump Lo LIe IusL cIurucLer oI LIe currenL IIne und swILcI Lo LIelInserL mode To swILcI Irom LIe commund mode Lo LIe vIsuuI mode Lype one oI v .swILcI Lo LIe vIsuuI mode (cIurucLer orIenLed) V .swILcI Lo LIe vIsuuI mode (IIne orIenLed) Ctrl-v .swILcI Lo LIe bIock-vIsuuI mode (seIecL recLungIes oI LexL) AII communds LIuL Luke u runge (Ior exumpIe subLILuLIon, deIeLe, copy or IndenLuLIon) work wILI LIe vIsuuI mode Loo. Movemen9 TIe sImpIesL movemenL communds ure h .move IeIL l .move rIgIL j .move up k .move down ObvIousIy LIese communds work onIy In LIe commund mode, oI course you cun uIso use LIe cursor keys (In uII LIree modes). TIere ure u IoL oI movemenL communds uvuIIubIe In VIm, `II onIy cover u Iew, buL II you need someLIIng specIuI very oILen Luke u Iook uL LIe IeIp, `m sure you`II IInd someLIIng usubIe.
VIm dIsLInguIsIes beLween screen-IInes (LIose sIown on LIe monILor) und reuI IInes (LIose ended wILI u new-IIne). So Iere LIe mosL ImporLunL communds 0 .IIrsL coIumn oI LIe IIne ^ .IIrsL non-bIunk cIurucLer oI LIe IIne w .jump Lo nexL word W .jump Lo nexL word, Ignore puncLuuLIon e .jump Lo word-end E .jump Lo word-end, Ignore puncLuuLIon b .jump Lo word-begInnIng B .jump Lo word-begInnIng, Ignore puncLuuLIon ge .jump Lo prevIous word-endIng gE .jump Lo prevIous word-endIng, Ignore puncLuuLIon g_ .jump Lo IusL non-bIunk cIurucLer oI LIe IIne $ .jump Lo LIe IusL cIurucLer oI LIe IIne I you remember jusL u Iew oI LIem, you`II geL very quIckIy Irom A Lo B! AnoLIer ImporLunL IucL Is, LIuL LIese communds gIve LIe runge Ior oLIer communds. Idi9ing nserLIng LexL Is preLLy sImpIe In VIm, jusL Lype i und sLurL LypIng. BuL VIm oIIers quILe sopIIsLIcuLed LexL-edILIng communds. d .deIeLe LIe cIurucLers Irom LIe cursor posILIon up LIe posILIon gIven by LIe nexL commund (Ior exumpIe d$ deIeLes uII cIurucLer Irom LIe currenL cursor posILIon up Lo LIe IusL coIumn oI LIe IIne). c .cIunge LIe cIurucLer Irom LIe cursor posILIon up Lo LIe posILIon IndIcuLed by LIe nexL commund. x .deIeLe LIe cIurucLer under LIe cursor. X .deIeLe LIe cIurucLer beIore LIe cursor (Buckspuce). y .copy LIe cIurucLers Irom LIe currenL cursor posILIon up Lo LIe posILIon IndIcuLed by LIe nexL commund. p .pusLe prevIous deIeLed or yunked (copIed) LexL uILer LIe currenL cursor posILIon. P .pusLe prevIous deIeLed or yunked (copIed) LexL beIore LIe currenL cursor posILIon. r .repIuce LIe currenL cIurucLer wILI LIe newIy Lyped one. s .subsLILuLe LIe LexL Irom LIe currenL cursor posILIon up Lo LIe posILIon gIven by LIe nexL commund wILI LIe newIy Lyped one. . .repeuL LIe IusL InserLIon or edILIng commund (x,d,p.). DoubIIng d, c or y operuLes on LIe wIoIe IIne, Ior exumpIe yy copIes LIe wIoIe IIne. PIeuse noLe, muny communds ure mucI more powerIuI LIun descrIbe LIem Iere. or exumpIe you cun specIIy u buIIer InLo some LexL Is yunked. TypIng "ayy copIes LIe currenL IIne InLo regIsLer a, pusLIng LIe conLenLs oI regIsLer a Is done by "ap. VIm remembers LIe IusL Iew yunks und deIeLIons In uuLomuLIc regIsLers, Lo sIow LIe conLenLs oI LIe regIsLers Lype :registers, you cun uIso use LIem Lo pusLe some oIder LexL. Visoul Block UsIng LIe vIsuuI bIock-mode IL`s possIbIe Lo InserL cIurucLers on eucI IIne oI LIe seIecLIon eusIIy. Suppose you Iuve seIecLed u recLungIe (usIng Ctrl-v), you cun InserL LexL In IronL oI IL by LypIng (swILcI Lo InserL mode) und InserLIng your LexL. As soon us you Ieuve LIe InserL mode, LIe LexL wIII be udded Lo uII LIe oLIer seIecLed IInes. Use A Lo enLer LexL uI9er LIe seIecLIon. AnoLIer useIuI IeuLure Is Lo subsLILuLe LIe wIoIe bIock wILI u new LexL. or LIuL muLLer seIecL u bIock und Lype s, VIm enLers LIe InserL mode und you cun Lype. AILer you Ieuve LIe InserL mode, VIm InserLs LIe LexL In LIe remuInIng IInes. I you`d IIke Lo uppend some LexL uL LIe end oI some IInes, use Ctrl-v$ und seIecL LIe IInes. TIe dIIIerence beLween LIe Iormer vurIunL Is, LIuL LIe $ expIIcILIy suys end oI IIne wIereus u seIecLIon wILI Ctrl-v operuLes on LIe coIumns, IgnorIng LIe LexL. UsIng Ctrl-v: This is a testNEWLY NSERTED This is a NEWLY NSERTED This is NEWLY NSERTED UsIng Ctrl-v$: This is a testNEWLY NSERTED This is aNEWLY NSERTED This isNEWLY NSERTED Tex9objec9s VIm communds operuLe on 9ex9objec9s LIese ure cIurucLers, words, cIurucLers deIImILed by purenLIeses, senLences und so on. or me LIe mosL ImporLunL one Is LIe inner ord: iw. To seIecL LIe currenL word, jusL Lype viw (v Ior seIecLIon mode, und iw Ior LIe inner ord), sImIIur Ior deIeLIon: diw. TIe dIIIerence beLween Inner-wordJbIock und u-wordJbIock eLc Is LIuL LIe Inner vurIunL seIecLs onIy LIe conLenLs IIke LIe cIurucLers oI LIe word (no bIunk uILerwurds) or LIe conLenLs oI LIe purenLIeses buL noL LIe purenLIeses. TIe u-vurIunL seIecLs LIe purenLIeses or u bIunk uILer u word Loo. iw .Inner word aw .u word iW .Inner WORD aW .u WORD is .Inner senLence as .u senLence ip .Inner purugrupI ap .u purugrupI i( or i) .Inner bIock a( or a) .u bIock i< or i> .Inner bIock a< or i> .u bIock i{ or i} .Inner bIock a{ or a} .u bIock i" .Inner bIock a" .u bIock i` .Inner bIock a` .u bIock Here u quIck vIsuuIIsuLIon oI LIe communds LIe coIor und LIe | | murk LIe seIecLed LexL: Commu nd Tex9 Objec9 iw TIIs Is u |LesL| senLence. aw TIIs Is u |LesL |senLence. iW TIIs Is u |.LesL.| senLence. aW TIIs Is u |.LesL. |senLence. is .senLence. |TIIs Is u senLence.| TIIs. as .senLence. |TIIs Is u senLence. |TIIs. ip End oI prevIous purugrupI.
|TIIs Is u purugrupI. L Ius Lwo senLences.|
TIe nexL. ap End oI prevIous purugrupI.
|TIIs Is u purugrupI. L Ius Lwo senLences.
|TIe nexL. i( or i) 1 (|z + |) a( or a) 1 |(z + )| i< or i> TIe <|Lug|> a< or i> TIe |<Lug>| i{ or i} some {| code bIock |] a{ or a} some |{ code bIock ]| i" TIe "|besL|" a" TIe| besL| i` TIe `|besL|` a` TIe| `besL`| Try LIem ouL und remember LIe ones you need reguIurIy (In my cuse iw und i() LIey ure LIe reuI LIme-suvers! Lndo und Redo Don`L be uIruId Lo Lry LIe vurIous communds, you cun undo uImosL unyLIIng usIng u In LIe commund mode - even undo Is undoubIe usIng Ctrl-r. VIm ;.o InLroduced undo-bruncIes, buL dIdn`L Iuve LIme Lo dIg deeper. Ix9ernul communds n VIm IL`s eusy Lo IncIude LIe ouLpuL oI exLernuI communds or Lo IIILer LIe wIoIe IIne or jusL u purL LIrougI un exLernuI IIILer. To Issue un exLernuI commund Lype :!command, LIe ouLpuL wIII be sIown und LIuL`s IL. To IIILer LIe LexL LIrougI un exLernuI commund Lype :!sort %. To InserL LIe ouLpuL oI LIe exLernuI commund In LIe currenL IIIe Lype :r!command (Ior exumpIe :r!which ls). SeurcI Ior IIILer Ior more InIormuLIon :h filter. Seurcing und Replucing SeurcIIng In VIm Is very eusy. Type / In LIe commund mode und InserL LIe Lerm you seurcI, und VIm wIII seurcI LIe IIIe (In Iorwurd dIrecLIon) Ior LIe Lerm. Use ? Ior LIe buckwurd dIrecLIon. UsIng n or N you cun repeuL LIe seurcI In LIe sume or opposILe dIrecLIon. I LIe opLIon IncseurcI Is seL, VIm ImmedIuLeIy jumps Lo LIe muLcIIng LexL wIen you enLer someLIIng. I IIseurcI Is seL, IL IIgIIIgILs uII muLcIes. To remove LIe IIgIIIgIL Lype :nohl. RepIucIng someLIIng Isn`L very Iurd Loo, buL you sIouId Iuve u good undersLundIng oI reguIur expressIons. To subsLILuLe u reguIur expressIon wILI some oLIer LexL, Lype :%s/old/new/gc LIIs commund Lukes LIe wIoIe IIIe %, und subsLILuLes s LIe word "oId wILI new und Iooks Ior more LIun one occurrence wILIIn one IIne g und usks II IL reuIIy sIouId repIuce LIe sIown one c. To repIuce some LexL onIy In u seIecLed ureu, seIecL LIe ureu, und Lype :s/old/new/g. TIIs sIouId Iook IIke :'<,'>s/old/new/g In LIe commund IIne. You`II undersLund '< und '> uILer LIe Murks secLIon. Comple9ion WIIIe you ure LypIng, IL`s preLLy common Lo use LIe sume word over und over uguIn. UsIng Ctrl-p VIm seurcIes LIe currenLIy Lyped LexL buckwurds Ior u word sLurLIng wILI LIe sume cIurucLers us uIreudy Lyped. Ctrl-x Ctrl-l compIeLes LIe wIoIe IIne. I you`re noL sure Iow Lo Lype some word und you`ve enubIed speII-cIeckIng (:set spell), you cun Lype Ctrl-x Ctrl-k Lo do u dIcLIonury Iookup Ior LIe uIreudy Lyped cIurucLers. VIm`s compIeLIon sysLem Ius mucI Improved durIng LIe IusL mujor upduLe (VIm ;.o). NoLe LIe compIeLIon communds work onIy In LIe inser9 mode, LIey Iuve oLIer meunIngs In LIe commund mode! Murks You cun seL murks wILIIn your documenLs Lo jump quIckIy beLween dIIIerenL posILIons oI u documenL or even muny documenLs. VIm uuLomuLIcuIIy seLs vurIous murks IIke {0-9} ure LIe IusL 1o posILIons oI cIosed IIIes (o LIe IusL, 1 LIe IusL buL one) < und > ure LIe IeIL und rIgIL posILIon oI murked LexLs ( und ) ure LIe sLurL or end oI LIe currenL senLence { und } ure LIe sLurL or end oI LIe currenL purugrupI [ und ] ure LIe IIrsL or IusL cIurucLer oI LIe IusL yunked or cIunged LexL . posILIon oI LIe IusL cIunge ' or ` posILIon beIore LIe IusL jump " posILIon beIore LIe IusL exIL oI LIe IIIe (IocuI Lo u IIIe) ^ posILIon oI LIe IusL InserL-sLop To seL u munuuI murk, use m{a-zA-Z} (m IoIIowed by eILIer u,b..z or A,B,..Z), und Lo jump Lo one oI LIe murks (munuuI or uuLomuLIc) you cun cIoose beLween ' und ` ' .seLs LIe cursor Lo LIe IIrsL non-bIunk cIurucLer In LIe murked IIne ` .seLs LIe cursor Lo LIe exucL posILIon wIere LIe murk wus seL TIere Is u IILLIe dIIIerence beLween Iower-cuse und upper- cuse cIurucLers: {a-z} ure IocuI Lo u IIIe {A-Z} ure sLored und uvuIIubIe over sessIons (ussocIuLed wILI u IIIe) You cun use L Ior your work-Iog und T Ior your LIme-LubIe Ior exumpIe, und quIckIy upduLe LIe InIormuLIon LIere. or exumpIe you cun jump Lo LIe IusL known posILIon oI u IIIe beIore IL wus cIosed by LypIng `" (IL`s eusy Lo conIIgure VIm Lo do IL uuLomuLIcuIIy uL sLurL). To geL u IIsL oI uII murks VIm knows ubouL Lype :marks. To deIeLe murks use :delmarks (:delmarks a b c removes murks a und b und c, Lo deIeLe uII murks use :delmarks!). Tubs, BoIIers und Windos VIm ;.o Ius InLroduced Lubs. We uII know und Iove Lubs, so IL`s noL mucI Lo suy Iere. (JusL u noLe: Lubs In VIm ure u bIL dIIIerenL LIun In oLIer progrums, you couId uIso LIInk oI LIem us muny VIm InsLunces In u Lubbed LermInuI wIndow. TIe dIIIerence Is, LIuL eucI Lub-puge cun Iuve IL`s own IuyouL. or exumpIe couId spIIL my screen oI LIe IIrsL Lub, und vIew LIe sume IIIe In one wIndow uL LIe second Lub. . So VIm-Lubs ure u bIL more powerIuI.) To open muny IIIes In Lubs vIu LIe commund IIne use vim -p *.txt. To swILcI beLween Lubs use LIe mouse (In gVIm) or Lype gt. To creuLe u new empLy Lub Lype :tabnew, or open u IIIe In u new Lub :tabe xyz. BuIIers und WIndows ure u bIL Iurder Lo undersLund. A wIndow Is wIuL you see wIen you open VIm, wIen you open LIe IeIp sysLem (by LypIng :help buffers), you`ve goL Lwo wIndows. So LIey ure no ucLuuI wIndows, buL vIew-porLs LIuL VIm oIIers. You cun open u wIndow und spIIL LIe currenL one IorIzonLuIIy usIng :sp or verLIcuIIy usIng :vsp. TIIs wuy VIm sIows you LIe sume boIIer In Lwo dIIIerenL wIndows. You cun open u new IIIe Loo, usIng :sp file or :vsp file. To swILcI beLween wIndows use LIe mouse or Lype Ctrl-w {hjkl} In LIe commund mode. A buIIer Is u IIIe (mosL oI LIe LIme), buL Isn`L necessurIIy vIsIbIe. So LIere ure usuuIIy more buIIers LIun wIndows. To sIow u dIIIerenL buIIer In LIe currenL wIndow, you cun swILcI LIem usIng :b NUMBER, wIere LIe buIIer number cun be Iooked up usIng :buffers. n LIe sLundurd conIIguruLIon VIm Iorces you Lo suve LIe currenLIy sIown buIIer beIore IL uIIows you Lo swILcI Lo unoLIer buIIer, so don`L be IrusLruLed by IL`s compIuIns. (Type :set hidden Lo enubIe unsuved buIIers, buL be cureIuI). Here my noLes Irom LIe IeIp-IIIe: :b N swILcI Lo buIIer N :buffers sIow buIIer IIsL. ExpIunuLIon: % currenL wIndow # uILernuLe buIIer (swILcI usIng :e# or :b#) a ucLIve (Iouded und vIsIbIe) h IIdden (Iouded buL noL vIsIbIe) + modIIIed :bd unIoud LIe buIIer und remove IL Irom buIIerIIsL (don`L cIose VIm,leven on LIe IusL buIIer) :bun unIoud LIe buIIer buL sLuy In buIIerIIsL :sp #N spIIL currenL wIndow und edIL buIIer N :w wrILe LIe currenL buIIer Lo dIsk :e file Ioud u IIIe Irom dIsk :q cIoses currenL wIndow (und VIm II IL`s LIe IusL one) :new new empLy wIndow :on cIose uII wIndows buL LIe ucLIve one (Ctrl-W o) Ctrl-W {h,j,k,l} move beLween wIndows AIIow modIIIed buIIers Lo be IIdden wIen LIe opLIon 'IIdden` Is seL. BuIIers ure uuLomuLIcuIIy suved II LIe opLIon 'IIdden` Is noL seL, buL 'uuLowrILe` Is seL. Mucros VIm uIIows Lo repIuy some communds usIng . (u doL). or more LIun one commund use mucros. You cun sLurL mucro-recordIng usIng q und one oI {o-qu-zA- Z], so Ior exumpIe qq records LIe mucro Lo buIIer q. HIL q wIen you ure IInIsIed recordIng. Now you cun repIuy LIe mucro uL uny LIme usIng q. Tis is 9e end Iope couId geL you sLurLed Ior musLerIng one oI LIe mosL sopIIsLIcuLed edILors ouL LIere. TIe IusL LIIng cun do now Is Lo IncIude my conIIguruLIon IIIe. Use :help ... Lo expIore VIm`s powers IurLIer und wrILe u LuLorIuI Ior LIe nexL upprenLIce. PIuce LIe vImrc InLo your Iome-dIrecLory (~/.vimrc), buL muke sure you don`L Iuve one uIreudy. 1 VIm Is un edi9or, no DE or operuLIng sysLem. Don`L Lry Lo muke un DE ouL oI IL, II you IIke DEs use one! OI course IL`s possIbIe Lo uuLomuLe muny Lusks, IIke compIIIng und jumpIng Lo errors reporLed by LIe compIIer, Ior LIuL muLLer Iook uL VIm`s pIugIns. http:blog.inteilinkeu.oigtutoiialsvimtutoiial.html
Top 10 things Vi user need to know about Vim 1. :help '2 has a extensive on-line help system. You can access this by using the: :help 2. You don't get the good features unless you turn them on By deIault '2 starts in ' compatibility mode. This means that most oI the good Ieatures are turned oII. The easiest way to turn them on is to create a $HOME/.vimrc Iile. Here's a sample one. (The documentation Ior this Iile is here.) One oI the Iirst Ieatures you'll notice when your create your .vimrc Iile is that you have more than one level oI undo. 3. Multiple Windows The command: :split splits the current window in two. You can then move the cursor up to a window with CTRL-W j and down a window with CTRL-W k. The command: :split file.txt splits the window and begins editing another Iile. To close a window, use the normal '2 exit commands or :q!. 4. Visual Mode Typing v causes '2. to enter "visual" mode. You can then highlight a block a text and then execute a '2 editing command such as d, y, or > on it. For example, let's highlight a block oI text starting with v and then moving the cursor. We now delete it with the d command. The v command selects text by character. The CTRL-V command selects text as a block. The V command selects line. 5. The 'incsearch' and 'hlsearch' options
The 'incsearch' option By deIault, searching starts aIter you enter the string. With the option: :set incsearch set, incremental searches will be done. The '2 editor will start searching when you type the Iirst character oI the search string. As you type in more characters, the search is reIined. The 'hlsearch' option The "highlight search option" ('hlsearch') turns on search highlighting. This option is enabled by the command: :set hlsearch AIter the option is enabled, any search highlights the string matched by the search. . The 'cindent' option and the command The ' editor has a 'autoindent' option which indents each line the same the previous one. The '2 editor does a much better job oI indentation. The 'cindent' option is set with the command: :set cindent This turns on C style indentation. Each new line will be automatically indented the correct amount according to the C indentation standard. . The :make command You've created a program. You've even got a MakeIile Ior it. Now you need to compile your program and correct the errors. To do this, start with the command: :make This runs the make command and captures the output. When the command Iinishes the editor starts editing the Iirst Iile. The next step is to Iix the error. AIter that you need to go to the line causing the next error. This is done using the command: :cn This command will go to the location oI the next error even iI it is in another Iile. You can continue Iixing problems and using :cn until all your problems are over or you want to do a recompile. II you want to see the current error message again, use the command: :cc . Tag navigation The command: $ ctags *.c generates a "table oI contents" Iile containing all the tags in the Iiles you've listed on the command. The name oI this Iile is tags. This Iile can be used by '2 to aide in the editing oI a program. The command: $ gvim -t a_function starts '2 and positions the cursor at the deIinition oI the Iunction "aIunction". (No matter what Iile it is in.) Tag Navigation Now suppose "aIunction" calls "writeblock": void a_function(void) { write_block(); //... You need to see what "writeblock" does. To do this, position the cursor over the "writeblock" call and press CTRL-]. The editor will jump to the deIinition oI "writeblock" (even iI it has to switch Iiles to do so.) Now "writeblock" calls "writechar". So you position the cursor over the "writechar" and press CTRL-]. The editor now jumps to the deIinition oI this Iunction. Having Iigured everything out, you can return up a level with the CTRL-T command. This causes you to go Irom "writechar" to the call in "writeblock". The next CTRL-T returns to the "writeblock" call in "aIunction". 9. Abbreviations We have the Iollowing abbreviations deIined in our ~/.vimrc. :ab #b /**************************************** :ab #e ^V^H*****************************************/ These let use deIine boxed comments with ease. By typing "#b" we type the top oI a boxed comment. Typing "#e" types the bottom line. (We put the `V`H`V`H in the Iile to backup over the comment leader.) These abbreviations were chosen to make the end oI the comment align on a tab boundary. 10. Word Completion When your typing and you enter a partial word, you can cause '2 to search Ior a completion by using the )P (search Ior previous marching word) and )N (search Ior next match). Links The main '2 site: http://www.vim.org
Nolepad Fror w|||ped|a, lre lree ercyc|oped|a
Notepad++
Nolepad 0eve|oper(s} 0or lo |n|t|a| re|ease Noveroer 21, 2003 8tab|e re|ease 5.9..1[1| (Noveroer 2011, 05; 2 days ago) [/-| wr|tten |n C 0perat|ng system V|crosoll w|rdoWs Ava||ab|e |n Vu|l|||rgua| (19) Type 3ource code ed|lor L|cense 0Nu 0erera| Puo||c L|cerse webs|te WWW.rolepad-p|us-p|us.org Notepad++ |s a lexl ed|lor ard source code ed|lor lor w|rdoWs. 0re advarlage ol Nolepad over lre ou||l-|r w|rdoWs lexl ed|lor, Nolepad, |s laooed ed|l|rg, Wr|cr a||oWs Wor||rg W|lr ru|l|p|e oper l||es. Nolepad |s d|slr|ouled as lree sollWare. Tre projecl |s rosled or 3ourceForge.rel, lror Wrere |l ras oeer doWr|oaded over 2Z r||||or l|res[2|[3| ard lW|ce Wor lre Corrur|ly Cro|ce AWard lor 8esl 0eve|oper Too|.[1| To d|sp|ay ard ed|l lexl ard prograrr|rg |arguage source code l||es, Nolepad uses lre 3c|rl|||a ed|lor corporerl.
Rurr|rg urder Vac 03 X us|rg lre w|re corpal|o|||ly |ayer. 3ource code ed|l|rg lealures |rc|ude:[5| Aulo-corp|el|or 8oo|rar|s 3yrlax r|gr||grl|rg ard syrlax lo|d|rg 8race ard |rderl r|gr||grl|rg Regu|ar express|or l|rd ard rep|ace 3peecr syrlres|s FTP 8roWser (p|ug-|r |rc|uded |r slardard |rsla||al|or) Vacro record|rg ard execul|or. var|ous loo|s sucr as ||re sorl|rg, lexl ercod|rg corvers|or, lexl lo|d|rg F||e slalus aulo-delecl|or P|ug|rs lor ru|l|||re regu|ar express|or searcr ard rep|ace Nolepad supporls syrlax r|gr||grl|rg ard syrlax lo|d|rg lor 52 prograrr|rg, scr|pl|rg, ard rar|up |arguages.[5|[Z| ll allerpls lo auloral|ca||y delecl lre |arguage lral a g|ver l||e uses, us|rg a rod|l|ao|e ||sl ol l||e exlers|or o|rd|rgs. users ray a|so rarua||y sel lre currerl |arguage, overr|d|rg lre exlers|or's delau|l |arguage. Tre prograr a|so supporls aulocorp|el|or lor a suosel ol lre APl ol sore prograrr|rg |arguages. 8upported Languages Acl|or3cr|pl Ada asp Assero|y auloll oasr 8alcr C C C Tre lo||oW|rg |arguages are ral|ve|y supporled oy Nolepad as ol vers|or 5.9.2: users car a|so del|re lre|r oWr |arguage (lor syrlax r|gr||grl|rg) ard |ls respecl|ve APl (lor aulocorp|el|or) oy us|rg lre ou||l-|r user Larguage 0el|re 3ysler.[5| users ray corl|gure lre syrlax r|gr||grl|rg's lorl sly|es per e|ererl, per |arguage, ard lre resu|l|rg lorralled scr|pl ray oe pr|rled |r lu||-co|or (wY3lwY0). Add|l|ora||y, Nolepad d|sp|ays |rderl gu|de||res Wrer source code |s |rderled W|lr lao craraclers, ard r|gr||grls c|os|rg oraces, orac|els ard lags.
P|ug|rs Nolepad ras supporl lor racros ard p|ug|rs.[8| Currerl|y, lrere are 2Z oll|c|a| p|ug|rs lor Nolepad, 10 ol Wr|cr are |rc|uded oy delau|l |r lre prograr.[9| Tre l|rsl p|ug|r lo oe |rc|uded |r lre prograr Was %09, Wr|cr |rc|udes lealures sucr as w3C va||dal|or lor lTVL ard C33, lexl sorl|rg, craracler case a|leral|or ard quole rard||rg.[10|
0eve|oprerl Tr|s projecl, oased or lre 3c|rl|||a ed|lor corporerl, |s Wr|ller |r C W|lr or|y w|r32 APl ca||s us|rg or|y lre 3TL |r order lo |rcrease perlorrarce ard reduce prograr s|ze. Tre a|r ol Nolepad |s lo reduce overa|| poWer corsurpl|or oy us|rg ell|c|erl o|rar|es lral requ|re |ess CPu poWer.[5|
8arred courlr|es ard corlroversy lr Varcr 2008, lre 8oycoll 8e|j|rg 2008 oarrer Was p|aced or Nolepad's 3ourceForge.rel rorepage.[11| A leW rorlrs |aler, rosl users |r Cr|ra Were urao|e lo F|asr Acl|or3cr|pl Forlra r 0u|1CLl las|e|| lTVL |r| l||e lrro3elup Java Javascr|pl J3 0ojecl|ve-C Pasca| Per| PlP PoWer3re|| Poslscr|pl Properl|es l||e Pylror R v L reacr lre 3ourceForge.rel Weos|le lor aooul a rorlr (Jure 2, 2008 - Ju|y 21, 2008). Tr|s |ead lo W|despread oe||el lral Cr|ra rad oarred 3ourceForge.rel |r rela||al|or lor lre 8oycoll oarrer. [12|[13|[11| lr Jaruary 2010, lre u3 goverrrerl lorced oper source projecl rosls lo corp|y W|lr u3 |aW ard dery access lror 5 courlr|es (Cuoa, lrar, Norlr Korea, 3udar, ard 3yr|a). As a resporse lo Wral lre deve|oper le|l Was a v|o|al|or ol lre Free ard 0per 3ource 3ollWare (F033) pr||osopry, |r Jure 2010, Nolepad roved oul ol u3 lerr|lor|a| jur|sd|cl|or oy re|eas|rg a vers|or or TuxFar||y, |r Frarce.[15|[1|
2.25 Software Engineering I General syntax of the C programming language Page Index Declarations Statements Expressions For this exposition, C code phrases are shown in fixed-width Iont keywords and standard types are in -oId Declarations declarations introduce new names and associate them with certain attributes simple variables typemark variable ; typemark is one oI char, short, int, long, float, double, void, a name deIined in a typedeI statement, or a name in struct-name space char, short, int, long may be preceded by signed or unsigned. deIault size oI int varies depending on compiler implementation variable (in regular expression notation) has the pattern |a- zA-Z||a-zA-Z0-9|* (one alphabetic Iollowed by zero or more alphanumeric) case is signiIicant structures struct structname { element_declarations } variable ; both structname and variable are optional, giving Iour diIIerent Iorms having neither structname nor variable is illegal structname is in struct-name space and must always be preceded by the keyword struct when used as typemark elementdeclarations are more or less any declaration elements are reIerenced by the notation variable.elementname enumerated constants enum enumname { enum_list } variable both enumname and variable are optional, giving Iour diIIerent Iorms having neither enumname nor variable is illegal (???) enumlist is usually a comma-sepearated list oI identiIiers, giving each identiIier increasing constant values starting at 0 optional Iorm iI identiIiers in enumlist is identifier : constant_expression enumname is in enum-name space and must be preceded by the keyword enum when used as typemark unions union unionname { element_declarations } variable ; both unionname and variable are optional, giving Iour diIIerent Iorms having neither unionname nor variable is illegal unionname is in union-name space and must be preceded by the keword union when used as a typemark element declarations in a union overlay the same memory arrays typemark variable [elementcount] ; arrays are origin zero elements are reIerenced by the notation variable[index] pointers typemark *variable ; pointers are dereIerenced by the notation *variable Iunctions typemark functionname ( parameter_list) block parameter list is a comman-separated list oI variable declarations the leading typemark is the Iunction's result type Iunctions are called by the notation Iunctioname(argumentlist) A Iunction with no result (a procedure) has the result type void A Iunction with no parameters has a parameterlist consisting oI the single keword void Statements expressions composed oI variables and literals composed with unary, binary, ternary, struct, array, and Iunction operators block list oI statements enclosed in and } block contains a scope names introduced in a block are visible only within the block control statements iteration (while, for, do), conditional (if, switch), and unconditional (break, continue, return, goto) general syntax Ior while, if, switch keyword ( expression ) statement statement must be block Ior switch general syntax Ior do do block whiIe (expression ) ; general syntax Ior for for ( initial; test; change) statement initial, test, change are expressions iterationsequence is initial test statement change test statement change ... break only valid within while, Ior, do, switch statements causes control to leave enclosing control statement continue only valid within while, Ior, do statements causes control to jump to change expression (or test expression iI construct has no change expression) return return expression expression is not allowed iI result type is void terminates current Iunction an returns expression as Iunction result to call site goto oto Ia-eI transIers control to statement with given label statement is labelled by preIixing with identifier : switch expression is coerced to integer cases are introduced by special Iorm oI label case constant_integer_expression : cases contain break Expressions precedence Operator escrpton ssoca ton x[i], f(x) .,-> array subscripting and Iunction call direct and indirect structure Iield selection leIt to righ t ++, -- ++, -- sizeof (950) +, -, !, ~ &, * :nary operators postIix increment and decrement preIix increment and decrement size oI a variable or type (in bytes) case to type unary plus and minus; logical and bitwise not address-oI, pointer dereIerence right to leIt *, /, % multiply, divide, modulus leIt to righ t +, - addition, subtraction >>, << shiIt right, shiIt leIt <, >, <=, >= order tests ==, != equality, inequality test & bitwise and ^ bitwise xor | bitwise or && logical and || logical or ? : (ternary operator) conditional right to leIt = +=, -=, *=, /=, %= <<=, >>= ^=, &=, |= assignment add to, subtract Irom multiply onto, divide into, assign remainder shiIt leIt, shiIt right assign bitwise xor, and, or right to leIt , sequential expression evaluation leIt to righ t 2.25 Software Engineering I General syntax of the C programming language Page Index Declarations Statements Expressions For this exposition, C code phrases are shown in fixed-width Iont keywords and standard types are in -oId Declarations declarations introduce new names and associate them with certain attributes simple variables typemark variable ; typemark is one oI char, short, int, long, float, double, void, a name deIined in a typedeI statement, or a name in struct-name space char, short, int, long may be preceded by signed or unsigned. deIault size oI int varies depending on compiler implementation variable (in regular expression notation) has the pattern |a- zA-Z||a-zA-Z0-9|* (one alphabetic Iollowed by zero or more alphanumeric) case is signiIicant structures struct structname { element_declarations } variable ; both structname and variable are optional, giving Iour diIIerent Iorms having neither structname nor variable is illegal structname is in struct-name space and must always be preceded by the keyword struct when used as typemark elementdeclarations are more or less any declaration elements are reIerenced by the notation variable.elementname enumerated constants enum enumname { enum_list } variable both enumname and variable are optional, giving Iour diIIerent Iorms having neither enumname nor variable is illegal (???) enumlist is usually a comma-sepearated list oI identiIiers, giving each identiIier increasing constant values starting at 0 optional Iorm iI identiIiers in enumlist is identifier : constant_expression enumname is in enum-name space and must be preceded by the keyword enum when used as typemark unions union unionname { element_declarations } variable ; both unionname and variable are optional, giving Iour diIIerent Iorms having neither unionname nor variable is illegal unionname is in union-name space and must be preceded by the keword union when used as a typemark element declarations in a union overlay the same memory arrays typemark variable [elementcount] ; arrays are origin zero elements are reIerenced by the notation variable[index] pointers typemark *variable ; pointers are dereIerenced by the notation *variable Iunctions typemark functionname ( parameter_list) block parameter list is a comman-separated list oI variable declarations the leading typemark is the Iunction's result type Iunctions are called by the notation Iunctioname(argumentlist) A Iunction with no result (a procedure) has the result type void A Iunction with no parameters has a parameterlist consisting oI the single keword void Statements expressions composed oI variables and literals composed with unary, binary, ternary, struct, array, and Iunction operators block list oI statements enclosed in and } block contains a scope names introduced in a block are visible only within the block control statements iteration (while, for, do), conditional (if, switch), and unconditional (break, continue, return, goto) general syntax Ior while, if, switch keyword ( expression ) statement statement must be block Ior switch general syntax Ior do do block whiIe (expression ) ; general syntax Ior for for ( initial; test; change) statement initial, test, change are expressions iterationsequence is initial test statement change test statement change ... break only valid within while, Ior, do, switch statements causes control to leave enclosing control statement continue only valid within while, Ior, do statements causes control to jump to change expression (or test expression iI construct has no change expression) return return expression expression is not allowed iI result type is void terminates current Iunction an returns expression as Iunction result to call site goto oto Ia-eI transIers control to statement with given label statement is labelled by preIixing with identifier : switch expression is coerced to integer cases are introduced by special Iorm oI label case constant_integer_expression : cases contain break Expressions precedence Operator escrpton ssoca ton x[i], f(x) .,-> array subscripting and Iunction call direct and indirect structure Iield selection leIt to righ t ++, -- ++, -- sizeof (950) +, -, !, ~ &, * :nary operators postIix increment and decrement preIix increment and decrement size oI a variable or type (in bytes) case to type unary plus and minus; logical and bitwise not address-oI, pointer dereIerence right to leIt *, /, % multiply, divide, modulus leIt to righ t +, - addition, subtraction >>, << shiIt right, shiIt leIt <, >, <=, >= order tests ==, != equality, inequality test & bitwise and ^ bitwise xor | bitwise or && logical and || logical or ? : (ternary operator) conditional right to leIt = +=, -=, *=, /=, %= <<=, >>= ^=, &=, |= assignment add to, subtract Irom multiply onto, divide into, assign remainder shiIt leIt, shiIt right assign bitwise xor, and, or right to leIt , sequential expression evaluation leIt to righ t