Movatterモバイル変換


[0]ホーム

URL:


Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq
Go to keyword (shortcut:k)
Site search (shortcut:s)
usr_05.txt  ForVim version 9.2.  Last change: 2026 Feb 14     VIM USER MANUALbyBramMoolenaar      Set your settingsVim can be tuned to work like you wantit to.  This chapter shows you how tomake Vim start withoptions set to different values.  Add plugins to extendVim's capabilities.  Or define your own macros.05.1  Thevimrc file05.2  The examplevimrc file explained05.3  Thedefaults.vim file explained05.4  Simple mappings05.5  Addinga package05.6  Addingaplugin05.7  Addingahelp file05.8  The optionwindow05.9  Often usedoptions     Next chapter:usr_06.txt  Usingsyntax highlighting Previous chapter:usr_04.txt  Making small changesTable of contents:usr_toc.txt==============================================================================05.1  Thevimrc filevimrc-introYou probably got tired of typing commands that you use very often.  To startVim with all your favorite option settings and mappings, you write them inwhatis called thevimrc file.  Vim executes the commands in this file whenitstarts up.If you already haveavimrc file (e.g., when your sysadmin has one setup foryou), you can editit this way::edit $MYVIMRCIf you don't haveavimrc file yet, seevimrc to find out where you cancreateavimrc file.  Also, the ":version" command mentions the name of the"uservimrc file" Vim looks for.ForUnix andMacintosh this fileis always used andis recommended:~/.vimrcForMS-Windows you can use one of these:$HOME/_vimrc$VIM/_vimrcIf you are creating thevimrc file for the first time,itis recommended toput this lineat the top:source $VIMRUNTIME/defaults.vimThis initializes Vim for new users (as opposed to traditionalVi users). Seedefaults.vim for the details.Thevimrc file can contain all the commands that you type aftera colon.  Thesimplest ones are for setting options.  For example, if you want Vim to alwaysstart with the'incsearch' option on, add this line yourvimrc file:set incsearchFor this new line to take effect you need to exit Vim and startit again.Later you will learn how todo this withoutexiting Vim.This chapter only explains the most basic items.  For more information on howto writea Vimscript file:usr_41.txt.==============================================================================05.2  The examplevimrc file explainedvimrc_example.vimIn the first chapter was explained how the examplevimrc (included in theVim distribution) file can be used to make Vimstartup innot-compatible mode(seenot-compatible).  The file can be found here:$VIMRUNTIME/vimrc_example.vimIn thissection we will explain thevarious commands used in this file.  Thiswill give you hints about how to set up your own preferences.  Not everythingwill be explained though.  Use the ":help" command to find out more." Get the defaults that most users want.source $VIMRUNTIME/defaults.vimThis loads the "defaults.vim" file in the$VIMRUNTIME directory.  This sets upVim for how most users like it.  If you are one of the few that don't, thencomment out this line.  The commands are explained below:defaults.vim-explainedif has("vms")  set nobackupelse  set backup  if has('persistent_undo')    set undofile  endifendifThis tells Vim to keepabackup copy ofa file when overwriting it.  But noton theVMS system, sinceit keeps old versions of files already.  Thebackupfile will have the same nameas the original file with "~" added.  See07.4This also sets the'undofile' option, if available.  This will store themulti-levelundo information ina file.  The resultis that when you changeafile, exit Vim, and then edit the file again, you canundo the changes madepreviously.  It'sa very powerful and useful feature,at the cost of storingafile.  For more information seeundo-persistence.The "if" commandis very useful to setoptionsonly when some conditionis met.  More about that inusr_41.txt.if &t_Co > 2 || has("gui_running")  set hlsearchendifThis switches on the'hlsearch' option, telling Vim to highlight matches withthe last used search pattern.augroup vimrcEx  au!  autocmd FileType text setlocal textwidth=78augroup ENDThis makes Vim break text to avoid lines getting longer than 78 characters.But only for files that have been detected to be plain text.  There areactually two parts here.  "autocmdFileType text"is an autocommand.  Thisdefines that when the file typeis set to "text" the following commandisautomatically executed.  "setlocal textwidth=78" sets the'textwidth' optionto 78, but only locally in one file.The wrapper with "augroup vimrcEx" and "augroup END" makesit possible todelete theautocommand with the "au!" command.  See:augroup.if has('syntax') && has('eval')  packadd! matchitendifThis loads the "matchit"plugin if the required features are available.It makes the% command more powerful.  Thisis explainedatmatchit-install.==============================================================================05.3  Thedefaults.vim file explaineddefaults.vim-explainedThedefaults.vim fileis loaded when the user has novimrc file.  When youcreatea newvimrc file, add this line near the top to keep using it:source $VIMRUNTIME/defaults.vimOr use thevimrc_example.vim file,as explained above.The following explains whatdefaults.vimis doing.if exists('skip_defaults_vim')  finishendifLoadingdefaults.vim can be disabled with this command:let skip_defaults_vim = 1This has to be done in the systemvimrc file.  Seesystem-vimrc.  If youhavea uservimrc thisis not needed, sincedefaults.vim will not be loadedautomatically.set nocompatibleAs mentioned in the first chapter, these manuals explain Vim working in animproved way, thus not completelyVi compatible.  Setting the'compatible'option off, thus'nocompatible' takes care of this.set backspace=indent,eol,startThisspecifies where inInsert mode the<BS>is allowed to delete thecharacter in front of the cursor.  The three items, separated by commas, tellVim to delete the whitespaceat the start of the line,a line break and thecharacter before whereInsert mode started.  See'backspace'.set history=200Keep 200 commands and 200 search patterns in the history.  Use another numberif you want to remember fewer or more lines.  See'history'.set rulerAlways display the current cursor position in the lower right corner of theVim window.  See'ruler'.set showcmdDisplay an incomplete command in the lower right corner of the Vim window,left of the ruler.  For example, when you type "2f", Vimis waiting for you totype the character to find and "2f"is displayed.  When you press "w" next,the "2fw" commandis executed and the displayed "2f"is removed.+-------------------------------------------------+|text in the Vimwindow  ||~  ||~  ||-- VISUAL--2f     43,8   17% |+-------------------------------------------------+ ^^^^^^^^^^^      ^^^^^^^^ ^^^^^^^^^^'showmode''showcmd''ruler'set wildmenuDisplay completion matches ina status line.  Thatis when you type<Tab> andthereis more than one match.  See'wildmenu'.set ttimeoutset ttimeoutlen=100This makes typing Esc take effect more quickly.  Normally Vim waitsa secondto see if the Escis the start of anescape sequence.  If you havea very slowremote connection, increase the number.  See'ttimeout'.set display=truncateShow @@@ in the last line ifitis truncated, instead of hiding the wholeline.  See'display'.set incsearchDisplay the match fora searchpattern when halfway typing it.  See'incsearch'.set nrformats-=octalDo not recognize numbersstarting witha zeroas octal.  See'nrformats'.map Q gqThis definesa key mapping.  More about that in the next section.  Thisdefines the "Q" command todoformatting with the "gq" operator.  Thisis howit worked before Vim 5.0.  Otherwise the "Q" command startsEx mode, but youwill not need it.inoremap <C-U> <C-G>u<C-U>CTRL-U ininsert mode deletes all entered text in the current line.  UseCTRL-Gu to first break undo, so that you canundoCTRL-U afterinsertingaline break.  Revert with ":iunmap<C-U>".if has('mouse')  set mouse=aendifEnable using the mouse if available.  See'mouse'.vnoremap _g y:exe "grep /" .. escape(@", '\\/') .. "/ *.c *.h"<CR>Thismapping yanks the visually selected text and searches forit inC files.You can see thatamapping can be used todo quite complicated things.  Still,itis justa sequence of commands that are executed like you typed them.syntax onEnable highlighting files in color.  Seesyntax.vimrc-filetypefiletype plugin indent onThis switches on three very clever mechanisms:1. Filetype detection.   Whenever you start editinga file, Vim will try to figure out what kind of   file this is.  When you edit "main.c", Vim will see the ".c" extension and   recognize thisasa "c" filetype.  When you edita file that starts with   "#!/bin/sh", Vim will recognizeitasa "sh" filetype.   Thefiletype detectionis used forsyntax highlighting and the other two   items below.   Seefiletypes.2. Usingfiletypeplugin files   Many differentfiletypes are edited with different options.  For example,   when you edita "c" file, it's very useful to set the'cindent' option to   automatically indent the lines.  These commonly useful option settings are   included with Vim infiletype plugins.  You can also add your own, seewrite-filetype-plugin.3. Using indent files   When editing programs, the indent ofa line can often be computed   automatically.  Vim comes with these indent rules fora number of   filetypes.  See:filetype-indent-on and'indentexpr'.restore-cursorlast-position-jump    augroup RestoreCursor      autocmd!      autocmd BufReadPost *        \ let line = line("'\"")        \ | if line >= 1 && line <= line("$") && &filetype !~# 'commit'        \      && index(['xxd', 'gitrebase'], &filetype) == -1        \      && !&diff        \ |   execute "normal! g`\""        \ | endif    augroup ENDAnother autocommand.  This timeitis used after reading any file.  Thecomplicated stuff afterit checks if the'"markis defined, and jumps toitif so.  It doesn'tdo that when:- editinga commit or rebase message, which are likelya different one than   last time,- using xxd(1) tofilter and edit binary files, which transforms input files   back and forth, causing them to have dual nature, so to speak (see alsousing-xxd) and- Vimis indiff modeThebackslashat the start ofa lineis used to continue the command from theprevious line.  That avoidsa line getting very long.  Seeline-continuation.This only works ina Vimscript file, not when typing commandsat thecommand line.command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_  \ | diffthis | wincmd p | diffthisThis adds the ":DiffOrig" command.  Use this ina modified buffer to see thedifferences with the fileit was loaded from.  Seediff and:DiffOrig.set nolangremapPrevent that the langmap option applies to characters that result fromamapping.  If set (default), this may break plugins (but it's backwardcompatible).  See'langremap'.==============================================================================05.4  Simple mappingsAmapping enables you to binda set of Vim commands toa single key.  Suppose,for example, that you need to surround certain words with curly braces.  Inother words, you need to changeaword suchas "amount" into "{amount}".  Withthe:map command, you can tell Vim that the F5 key does this job.  The commandisas follows::map <F5> i{<Esc>ea}<Esc>Note:When entering this command, youmust enter<F5> by typing fourcharacters.  Similarly,<Esc>is not entered by pressing the<Esc>key, but by typing five characters.  Watch out for this differencewhen reading the manual!Let's break this down:<F5>The F5 function key.  Thisis the trigger key that causes thecommand to be executedas the keyis pressed.    i{<Esc>Insert the{ character.  The<Esc> key endsInsert mode.eMove to theend of the word.    a}<Esc>Append the} to the word.After you execute the ":map" command, all you have todo toput{} aroundawordis toput the cursor on the first character and press F5.In this example, the triggerisa single key;it can be any string.  But whenyou use an existing Vim command, that command will no longer be available.You better avoid that.   One key that can be used with mappingsis the backslash.  Since youprobably want to define more than one mapping, add another character.  Youcould map "\p" to add parentheses arounda word, and "\c" to add curly braces,for example::map \p i(<Esc>ea)<Esc>:map \c i{<Esc>ea}<Esc>You need to type the \ and thep quickly after another, so that Vim knows theybelong together.The ":map" command (with no arguments) lists your current mappings.  Atleast the ones forNormal mode.  More about mappings insection40.1.==============================================================================05.5  Addinga packageadd-packageA packageisa set of files that you can add to Vim.  There are two kinds ofpackages: optional and automatically loaded on startup.The Vimdistribution comes witha fewpackages that you can optionally use.------------------------------------------------------------------------------Adding thematchit packagematchit-installpackage-matchit------------------------------------------------------------------------------For example, thematchit package  Thisplugin makes the "%" command jump tomatching HTML tags, if/else/endif in Vim scripts, etc.  Very useful, althoughit's not backwards compatible (that's whyitis not enabled by default).To start using thematchit plugin, add one line to yourvimrc file:packadd! matchitThat's all!  After restarting Vim you can findhelp about this plugin::help matchitThis works, because when:packadd loaded thepluginit also added thepackage directory in'runtimepath', so that thehelp file can be found.You can findpackages on the Internet invarious places.  It usually comesasan archive orasa repository.  For an archive you can follow these steps:1. create the package directory:mkdir -p ~/.vim/pack/fancy   "fancy" can be any name of your liking.  Use one that describes the   package.2. unpack the archive in that directory.  This assumes the top   directory in the archiveis "start":cd ~/.vim/pack/fancyunzip /tmp/fancy.zip   If the archive layoutis different make sure that youend up witha   path like this:~/.vim/pack/fancy/start/fancytext/plugin/fancy.vim   Here "fancytext"is the name of the package,it can be anything   else.------------------------------------------------------------------------------Adding the editorconfig packageeditorconfig-installpackage-editorconfig------------------------------------------------------------------------------Similar to thematchit package, to load the distributed editorconfigpluginwhen Vim starts, add the following line to yourvimrc file:packadd! editorconfigAfter restarting your Vim, thepluginis active and you can read aboutit at::h editorconfig.txt------------------------------------------------------------------------------Adding the comment packagecomment-installpackage-comment------------------------------------------------------------------------------Load theplugin with this command:packadd commentThis way you can use theplugin with the default key bindingsgc and similarfor commenting (whichisa well-establishedmapping in the Vim community).If you add this line to yourvimrc file, then you need to restart Vim to havethe package loaded.  Once the packageis loaded, read aboutit at::h comment.txt------------------------------------------------------------------------------Adding the nohlsearch packagenohlsearch-installpackage-nohlsearch------------------------------------------------------------------------------Load theplugin with this command:packadd nohlsearchAutomatically execute:nohlsearch after'updatetime' or getting intoInsert mode.Thus assuming default updatetime, hlsearch would be suspended/turned off after4 seconds of idle time.To disable the effect of theplugin afterit has been loaded:au! nohlsearch------------------------------------------------------------------------------Adding the highlight-yank packagehlyank-installpackage-hlyank------------------------------------------------------------------------------Load theplugin with this command:packadd hlyankThis package briefly highlights the affected region of the lastyankcommand.  See52.6 fora simplified implementation using thegetregionpos() function.Theplugin understands the following configurationvariables (the settingsshow the default values).To specifya different highlighting group, use::let g:hlyank_hlgroup = 'IncSearch'To usea different highlighting duration, use::let g:hlyank_duration = 300The unitis milliseconds, and the upper limitis 3000 ms.  If you seta valuehigher than this, the highlighting duration will be 3000 ms.To highlight in visual mode, use::let g:hlyank_invisual = v:trueTo disable the effect of theplugin afterit has been loaded:au! hlyank------------------------------------------------------------------------------Adding the osc52 packageosc52-installpackage-osc52------------------------------------------------------------------------------Load theplugin with this command:packadd osc52The osc52.vim package provides support for the OSC 52terminal command, whichallows an application to access theclipboard by communicating directly withyour terminal.Once the packageis loaded, read aboutit at::h osc52.txtMore information aboutpackages can be found here:packages.==============================================================================05.6  Addingapluginadd-pluginpluginVim's functionality can be extended by adding plugins.Apluginis nothingmore thana Vimscript file thatis loaded automatically when Vim starts.  Youcan addaplugin very easily by droppingit in yourplugin directory.{not available when Vim was compiled without the |+eval| feature}There are two types of plugins:    global plugin: Used for all kinds of filesfiletype plugin: Only used fora specific type of fileThe global plugins will be discussed first, then thefiletype onesadd-filetype-plugin.GLOBAL PLUGINSstandard-plugindistributed-pluginsWhen you start Vim,it will automatically loada number of global plugins.You don't have todo anything for this.  They add functionality that mostpeople will want to use, but which was implementedasa Vimscript instead ofbeing compiled into Vim.  You can find them listed in thehelpindexstandard-plugin-list.For locally installed plugins andpackages (which come witha separatedhelpfile)a similarlist can be found in thehelpsectionlocal-additions.Also seeload-plugins.add-global-pluginYou can adda globalplugin to add functionality that will always be presentwhen you use Vim.  There are only two steps for addinga global plugin:1. Geta copy of the plugin.2. Dropit in the right directory.GETTING A GLOBAL PLUGINWhere can you find plugins?- Some are always loaded, you can see them in the directory  $VIMRUNTIME/plugin.- Some come with Vim.  You can find them in the directory $VIMRUNTIME/macros  and its sub-directories and under $VIM/vimfiles/pack/dist/opt/.- Download from the net.  Thereisa large collection onhttp://www.vim.org.- They are sometimes posted ina Vimmaillist.- You could write one yourself, seewrite-plugin.Some plugins comeasavimball archive, seevimball.Some plugins can be updated automatically, seegetscript.USING A GLOBAL PLUGINFirst read the text in theplugin itself to check for any special conditions.Then copy the file to yourplugin directory:systemplugin directoryUnix~/.vim/plugin/PC$HOME/vimfiles/plugin or $VIM/vimfiles/pluginAmigas:vimfiles/pluginMacintosh$VIM:vimfiles:pluginMac OSX~/.vim/plugin/Example forUnix (assuming you didn't haveaplugin directory yet):mkdir ~/.vimmkdir ~/.vim/plugincp /tmp/yourplugin.vim ~/.vim/pluginThat's all!  Now you can use the commands defined in this plugin.Instead of putting plugins directly into the plugin/ directory, you maybetter organize them by putting them into subdirectories under plugin/.As an example, consider using "~/.vim/plugin/perl/*.vim" for all yourPerlplugins.FILETYPE PLUGINSadd-filetype-pluginftpluginsThe Vimdistribution comes witha set of plugins for differentfiletypes thatyou can start using with this command::filetype plugin onThat's all!  Seevimrc-filetype.If you are missingaplugin forafiletype you are using, or you foundabetter one, you can add it.  There are two steps for addingafiletype plugin:1. Geta copy of the plugin.2. Dropit in the right directory.GETTING A FILETYPE PLUGINYou can find them in the same placesas the global plugins.  Watch out if thetype of fileis mentioned, then you know if thepluginisa global orafiletype one.  The scripts in $VIMRUNTIME/macros are global ones, thefiletypeplugins are in $VIMRUNTIME/ftplugin.USING A FILETYPE PLUGINftplugin-nameYou can addafiletypeplugin by droppingit in the right directory.  Thename of this directoryis in the same directory mentioned above for globalplugins, but the last partis "ftplugin".  Suppose you have foundaplugin forthe "stuff" filetype, and you are on Unix.  Then you can move this file to theftplugin directory:mv thefile ~/.vim/ftplugin/stuff.vimIf that file already exists you already haveaplugin for "stuff".  You mightwant to check if the existingplugin doesn't conflict with the one you areadding.  If it's OK, you can give the new one another name:mv thefile ~/.vim/ftplugin/stuff_too.vimThe underscoreis used to separate the name of thefiletype from the rest,which can be anything.  If you use "otherstuff.vim"it wouldn't work,it wouldbe loaded for the "otherstuff" filetype.OnMS-DOS like filesystems you cannot use long filenames.  You would run intotrouble if you adda secondplugin and thefiletype has more than sixcharacters.  You can use an extra directory to get around this:mkdir $VIM/vimfiles/ftplugin/fortrancopy thefile $VIM/vimfiles/ftplugin/fortran/too.vimThe generic names for thefiletype plugins are:ftplugin/<filetype>.vimftplugin/<filetype>_<name>.vimftplugin/<filetype>/<name>.vimHere "<name>" can be any name that you prefer.Examples for the "stuff"filetype on Unix:~/.vim/ftplugin/stuff.vim~/.vim/ftplugin/stuff_def.vim~/.vim/ftplugin/stuff/header.vimThe<filetype> partis the name of thefiletype thepluginis to be used for.Only files of thisfiletype will use the settings from the plugin.  The<name>part of theplugin file doesn't matter, you can useit to have several pluginsfor the same filetype.Note thatitmustend in ".vim".Further reading:filetype-plugins  Documentation for thefiletype plugins and informationabout how to avoid that mappings cause problems.load-plugins  When the global plugins are loaded during startup.ftplugin-overrule  Overruling the settings froma global plugin.write-plugin  How to writeaplugin script.plugin-details  For more information about using plugins or when yourplugin doesn't work.new-filetype  How to detecta new file type.==============================================================================05.7  Addingahelp fileadd-local-helpIf you are lucky, theplugin you installed also comes withahelp file.  Wewill explain how toinstall thehelp file, so that you can easily findhelpfor your new plugin.   Let us use the "doit.vim"pluginas an example.  Thisplugin comes withdocumentation: "doit.txt".  Let's first copy theplugin to the rightdirectory.  This time we willdoit from inside Vim.  (You may skip some ofthe "mkdir" commands if you already have the directory.):!mkdir ~/.vim:!mkdir ~/.vim/plugin:!cp /tmp/doit.vim ~/.vim/pluginThe "cp" commandis for Unix, onMS-Windows you can use "copy".Now createa "doc" directory in one of the directories in'runtimepath'.:!mkdir ~/.vim/docCopy thehelp file to the "doc" directory.:!cp /tmp/doit.txt ~/.vim/docNow comes the trick, which allows you to jump to the subjects in the newhelpfile: Generate the localtags file with the:helptags command.:helptags ~/.vim/docNow you can use the:help doitcommand to findhelp for "doit" in thehelp file you just added.  You can seean entry for the localhelp file when you do::help local-additionsThe title lines from the localhelp files are automagically added to thissection.  There you can see which localhelp files have been added and jump tothem through the tag.Forwritinga localhelp file, seewrite-local-help.==============================================================================05.8  The optionwindowIf you are looking for an option that does what you want, you can search inthehelp files here:options.  Another wayis by using this command::optionsThis opensa new window, withalist ofoptions witha one-line explanation.Theoptions are grouped by subject.  Move the cursor toa subject and press<Enter> to jump there.  Press<Enter> again to jump back.  Or useCTRL-O.You can change the value of an option.  For example, move to the "displayingtext" subject.  Then move the cursor down to this line:set wrapnowrapWhen you hit<Enter>, the line will change to:set nowrapwrapThe option has now been switched off.Just above this lineisa short description of the'wrap' option.  Move thecursor one line up to placeit in this line.  Now hit<Enter> and you jump tothe fullhelp on the'wrap' option.Foroptions that takea number orstring argument you can edit the value.Then press<Enter> to apply the new value.  For example, move the cursora fewlines up to this line:set so=0Position the cursor on the zero with "$".  Changeit intoa five with "r5".Then press<Enter> to apply the new value.  When you now move the cursoraround you will notice that the text startsscrolling before you reach theborder.  Thisis what the'scrolloff' option does,itspecifies an offsetfrom thewindow border wherescrolling starts.==============================================================================05.9  Often usedoptionsThere are an awful lot of options.  Most of them you will hardly ever use.Some of the more useful ones will be mentioned here.  Don't forget you canfind morehelp on theseoptions with the ":help" command, with singlequotesbefore and after the option name.  For example::help 'wrap'Incase you have messed up an option value, you can setit back to thedefault by putting an ampersand (&) after the option name.  Example::set iskeyword&NOT WRAPPING LINESVim normally wraps long lines, so that you can see all of the text.  Sometimesit's better to let the text continue right of the window.  Then you need toscroll the text left-right to see all ofa long line.  Switch wrapping offwith this command::set nowrapVim will automatically scroll the text when you move to text thatis notdisplayed.  To seea context of ten characters,do this::set sidescroll=10This doesn't change the text in the file, only the wayitis displayed.WRAPPING MOVEMENT COMMANDSMost commands for moving around will stop movingat the start andend ofaline.  You can change that with the'whichwrap' option.  This setsit to thedefault value::set whichwrap=b,sThis allows the<BS> key, when used in the first position ofa line, to movethe cursor to theend of the previous line.  And the<Space> key moves fromtheend ofa line to the start of the next one.To allow the cursor keys<Left> and<Right> to also wrap, use this command::set whichwrap=b,s,<,>Thisis still only forNormal mode.  To let<Left> and<Right>do this inInsert modeas well::set whichwrap=b,s,<,>,[,]There area few other flags that can be added, see'whichwrap'.VIEWING TABSWhen there are tabs ina file, you cannot see where they are.  To make themvisible::set listNow everytabis displayedas ^I.  Anda$is displayedat theend of eachline, so that you can spot trailing spaces that would otherwisego unnoticed.A disadvantageis that this looks ugly when there are many Tabs ina file.If you havea color terminal, or are using the GUI, Vim can show the spacesand tabsas highlighted characters.  Use the'listchars' option::set listchars=tab:>-,trail:-Now everytab will be displayedas ">---" (with more orless "-") and trailingwhitespaceas "-".  Looksa lot better, doesn't it?KEYWORDSThe'iskeyword' optionspecifies which characters can appear ina word::set iskeyword  iskeyword=@,48-57,_,192-255The "@" stands for all alphabetic letters.  "48-57" stands for ASCIIcharacters 48 to 57, which are the numbers0 to 9.  "192-255" are theprintable latin characters.   Sometimes you will want to includea dash in keywords, so that commandslike "w" consider "upper-case" to be one word.  You candoit like this::set iskeyword+=-:set iskeyword  iskeyword=@,48-57,_,192-255,-If you lookat the new value, you will see that Vim has addeda comma for you.   To removea character use "-=".  For example, to remove the underscore::set iskeyword-=_:set iskeyword  iskeyword=@,48-57,192-255,-This timea commais automatically deleted.ROOM FOR MESSAGESWhen Vim starts thereis one lineat the bottom thatis used for messages.Whena messageis long,itis either truncated, thus you can only see part ofit, or the text scrolls and you have to press<Enter> to continue.   You can set the'cmdheight' option to the number of lines used formessages.  Example::set cmdheight=3This does mean thereisless room to edit text, thus it'sa compromise.==============================================================================Next chapter:usr_06.txt  Usingsyntax highlightingCopyright: seemanual-copyright  vim:tw=78:ts=8:noet:ft=help:norl:

Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq


[8]ページ先頭

©2009-2026 Movatter.jp