Permalink
..
Failed to load latest commit information.
GvimExt patch 8.0.0029 Oct 12, 2016
MacVim MacVim Snapshot 121 Jan 12, 2017
VisVim patch 7.4.1883 Jun 2, 2016
auto Fix Homebrew build Jan 5, 2017
create-dmg Add DMG background source in pixlr.com format Jul 18, 2015
if_perl_msvc patch 7.4.1011 Dec 31, 2015
os_mac_rsrc updated for version 7.0d01 Apr 11, 2006
po Update runtime files. Jan 17, 2017
proto Merge remote-tracking branch 'vim/master' Jan 13, 2017
tee patch 7.4.1240 Feb 2, 2016
testdir Merge remote-tracking branch 'vim/master' Jan 18, 2017
xpm patch 7.4.2135 Jul 31, 2016
xxd patch 7.4.2048 Jul 16, 2016
INSTALL patch 8.0.0082 Nov 12, 2016
INSTALLami.txt
INSTALLmac.txt
INSTALLpc.txt patch 8.0.0007 Sep 21, 2016
INSTALLvms.txt updated for version 7.3.925 May 6, 2013
INSTALLx.txt First step in the Vim 7.3 branch. Changed version numbers. May 15, 2010
Make_bc5.mak patch 7.4.2069 Jul 19, 2016
Make_cyg.mak updated for version 7.4.496 Feb 12, 2015
Make_cyg_ming.mak patch 8.0.0115 Dec 1, 2016
Make_dice.mak patch 7.4.2069 Jul 19, 2016
Make_dvc.mak updated for version 7.0001 Jun 13, 2004
Make_ivc.mak
Make_manx.mak
Make_ming.mak updated for version 7.4.496 Feb 12, 2015
Make_mint.mak updated for version 7.2a Jun 24, 2008
Make_morph.mak
Make_mvc.mak patch 8.0.0144: when using MSVC the GvimExt directory is cleaned twice Jan 6, 2017
Make_sas.mak patch 7.4.2069 Jul 19, 2016
Make_vms.mms patch 8.0.0059 Nov 4, 2016
Makefile Merge remote-tracking branch 'vim/master' Jan 18, 2017
README.txt
alloc.h patch 7.4.2293 Aug 29, 2016
appveyor.bat
arabic.c
arabic.h patch 7.4.2293 Aug 29, 2016
ascii.h patch 7.4.2293 Aug 29, 2016
bigvim.bat patch 7.4.2366 Sep 12, 2016
bigvim64.bat
blowfish.c patch 8.0.0082 Nov 12, 2016
buffer.c Merge remote-tracking branch 'vim/master' Jan 14, 2017
channel.c Merge remote-tracking branch 'vim/master' Jan 15, 2017
charset.c patch 8.0.0164: outdated and misplaced comments Jan 10, 2017
config.aap.in patch 7.4.1897 Jun 4, 2016
config.h.in
config.mk.dist updated for version 7.0001 Jun 13, 2004
config.mk.in
configure Restore 'src/configure' script from upstream Jun 23, 2013
configure.ac Fix Homebrew build Jan 5, 2017
crypt.c patch 7.4.2293 Aug 29, 2016
crypt_zip.c patch 7.4.2293 Aug 29, 2016
dehqx.py updated for version 7.3.567 Jun 29, 2012
dict.c patch 8.0.0074 Nov 10, 2016
diff.c patch 8.0.0044 Oct 18, 2016
digraph.c patch 8.0.0062 Nov 4, 2016
dimm.idl updated for version 7.0001 Jun 13, 2004
dlldata.c updated for version 7.0001 Jun 13, 2004
dosinst.c patch 7.4.2293 Aug 29, 2016
dosinst.h patch 7.4.2293 Aug 29, 2016
edit.c Merge remote-tracking branch 'vim/master' Dec 10, 2016
eval.c
evalfunc.c Merge remote-tracking branch 'vim/master' Jan 18, 2017
ex_cmds.c patch 8.0.0177: BufEnter autocommand not fired for a directory Jan 13, 2017
ex_cmds.h Merge remote-tracking branch 'vim/master' Nov 16, 2016
ex_cmds2.c
ex_docmd.c Merge remote-tracking branch 'vim/master' Jan 14, 2017
ex_eval.c patch 8.0.0075 Nov 10, 2016
ex_getln.c Merge remote-tracking branch 'vim/master' Jan 12, 2017
farsi.c patch 7.4.2293 Aug 29, 2016
farsi.h patch 7.4.2293 Aug 29, 2016
feature.h Merge remote-tracking branch 'vim/master' Sep 7, 2016
fileio.c Merge remote-tracking branch 'vim/master' Jan 14, 2017
fold.c patch 7.4.2293 Aug 29, 2016
getchar.c Merge remote-tracking branch 'vim/master' Jan 12, 2017
glbl_ime.cpp
glbl_ime.h patch 7.4.2293 Aug 29, 2016
globals.h Merge remote-tracking branch 'vim/master' Nov 29, 2016
gui.c Merge remote-tracking branch 'vim/master' Aug 30, 2016
gui.h Merge remote-tracking branch 'vim/master' Sep 10, 2016
gui_at_fs.c patch 7.4.2293 Aug 29, 2016
gui_at_sb.c patch 7.4.2293 Aug 29, 2016
gui_at_sb.h patch 7.4.2293 Aug 29, 2016
gui_athena.c patch 7.4.2293 Aug 29, 2016
gui_beval.c Merge remote-tracking branch 'vim/master' Nov 18, 2016
gui_beval.h Merge remote-tracking branch 'vim/master' Aug 30, 2016
gui_dwrite.cpp patch 7.4.1610 Mar 19, 2016
gui_dwrite.h updated for version 7.4.393 Feb 12, 2015
gui_gtk.c patch 8.0.0162: build error on Fedora 23 Jan 9, 2017
gui_gtk_f.c
gui_gtk_f.h patch 7.4.2293 Aug 29, 2016
gui_gtk_res.xml patch 7.4.1019 Jan 1, 2016
gui_gtk_vms.h patch 7.4.2293 Aug 29, 2016
gui_gtk_x11.c patch 8.0.0162: build error on Fedora 23 Jan 9, 2017
gui_mac.c
gui_motif.c
gui_photon.c
gui_w32.c patch 8.0.0114 Dec 1, 2016
gui_w32_rc.h
gui_x11.c patch 7.4.2293 Aug 29, 2016
gui_x11_pm.h patch 7.4.2293 Aug 29, 2016
gui_xmdlg.c patch 7.4.2293 Aug 29, 2016
gui_xmebw.c patch 7.4.2293 Aug 29, 2016
gui_xmebw.h patch 7.4.2293 Aug 29, 2016
gui_xmebwp.h patch 7.4.2293 Aug 29, 2016
gvim.exe.mnf
gvimtutor updated for version 7.1-298 May 10, 2008
hangulin.c
hardcopy.c patch 7.4.2293 Aug 29, 2016
hashtab.c patch 8.0.0192: cannot build with tiny features Jan 15, 2017
if_cscope.c patch 8.0.0192: cannot build with tiny features Jan 15, 2017
if_cscope.h patch 7.4.2293 Aug 29, 2016
if_lua.c patch 7.4.2285 Aug 28, 2016
if_mzsch.c patch 7.4.2293 Aug 29, 2016
if_mzsch.h patch 7.4.2293 Aug 29, 2016
if_ole.cpp patch 7.4.2293 Aug 29, 2016
if_ole.h updated for version 7.3.199 May 25, 2011
if_ole.idl updated for version 7.1-282 Mar 16, 2008
if_perl.xs patch 7.4.2293 Aug 29, 2016
if_perlsfio.c patch 7.4.2293 Aug 29, 2016
if_py_both.h patch 7.4.2257 Aug 26, 2016
if_python.c
if_python3.c Fix Py_SetPythonHome calling Dec 9, 2016
if_ruby.c Merge remote-tracking branch 'vim/master' Jan 18, 2017
if_tcl.c patch 7.4.2293 Aug 29, 2016
if_xcmdsrv.c Merge remote-tracking branch 'vim/master' Aug 30, 2016
iid_ole.c
infplist.xml updated for version 7.0c10 Apr 5, 2006
installman.sh updated for version 7.4.340 Jun 25, 2014
installml.sh updated for version 7.0g Apr 30, 2006
integration.c patch 7.4.2293 Aug 29, 2016
integration.h
iscygpty.c
iscygpty.h patch 7.4.1963 Jun 26, 2016
json.c patch 8.0.0180: error E937 is used twice Jan 14, 2017
json_test.c patch 8.0.0171: JS style JSON does not support single quotes Jan 11, 2017
keymap.h Merge remote-tracking branch 'vim/master' Aug 30, 2016
link.390 updated for version 7.0001 Jun 13, 2004
link.sh updated for version 7.3.050 Nov 3, 2010
list.c patch 8.0.0164: outdated and misplaced comments Jan 10, 2017
macros.h patch 8.0.0067 Nov 6, 2016
main.aap patch 8.0.0082 Nov 12, 2016
main.c Merge remote-tracking branch 'vim/master' Nov 29, 2016
mark.c patch 8.0.0039 Oct 15, 2016
mbyte.c Merge remote-tracking branch 'vim/master' Jan 13, 2017
memfile.c patch 8.0.0074 Nov 10, 2016
memfile_test.c patch 7.4.2293 Aug 29, 2016
memline.c patch 8.0.0177: BufEnter autocommand not fired for a directory Jan 13, 2017
menu.c Merge remote-tracking branch 'vim/master' Aug 30, 2016
message.c Merge remote-tracking branch 'vim/master' Jan 15, 2017
message_test.c patch 7.4.2293 Aug 29, 2016
misc1.c Merge remote-tracking branch 'vim/master' Jan 13, 2017
misc2.c Merge remote-tracking branch 'vim/master' Jan 12, 2017
mkinstalldirs updated for version 7.2.329 Jan 12, 2010
move.c
msvc2008.bat updated for version 7.3.1308 Jul 4, 2013
msvc2010.bat updated for version 7.3.1308 Jul 4, 2013
msvcsetup.bat updated for version 7.0216 Mar 6, 2006
mysign patch 8.0.0082 Nov 12, 2016
nbdebug.c patch 8.0.0012 Sep 25, 2016
nbdebug.h patch 7.4.2293 Aug 29, 2016
netbeans.c Merge remote-tracking branch 'vim/master' Sep 26, 2016
normal.c Merge remote-tracking branch 'vim/master' Jan 15, 2017
ops.c patch 8.0.0140 Jan 2, 2017
option.c
option.h Merge remote-tracking branch 'vim/master' Jan 15, 2017
os_amiga.c
os_amiga.h
os_beos.c patch 7.4.2293 Aug 29, 2016
os_beos.h patch 7.4.2293 Aug 29, 2016
os_beos.rsrc updated for version 7.0001 Jun 13, 2004
os_dos.h patch 7.4.2293 Aug 29, 2016
os_mac.h patch 7.4.2293 Aug 29, 2016
os_mac.rsr.hqx updated for version 7.0001 Jun 13, 2004
os_mac_conv.c patch 7.4.2293 Aug 29, 2016
os_macosx.m Merge remote-tracking branch 'vim/master' Aug 30, 2016
os_mint.h patch 7.4.2293 Aug 29, 2016
os_mswin.c patch 8.0.0114 Dec 1, 2016
os_qnx.c patch 7.4.2293 Aug 29, 2016
os_qnx.h patch 7.4.2293 Aug 29, 2016
os_unix.c Merge remote-tracking branch 'vim/master' Jan 18, 2017
os_unix.h patch 8.0.0059 Nov 4, 2016
os_unixx.h patch 8.0.0173: build fails with EBCDIC defined Jan 12, 2017
os_vms.c
os_vms_conf.h patch 8.0.0109 Dec 1, 2016
os_vms_fix.com
os_vms_mms.c updated for version 7.0073 May 19, 2005
os_w32dll.c patch 7.4.2293 Aug 29, 2016
os_w32exe.c patch 7.4.2293 Aug 29, 2016
os_win32.c patch 8.0.0175: setting language on MS-Windows does not always work Jan 12, 2017
os_win32.h
osdef.sh patch 7.4.1159 Jan 23, 2016
osdef1.h.in patch 8.0.0109 Dec 1, 2016
osdef2.h.in patch 7.4.1159 Jan 23, 2016
pathdef.sh updated for version 7.0001 Jun 13, 2004
popupmnu.c
proto.h
pty.c patch 8.0.0123 Dec 3, 2016
quickfix.c patch 8.0.0084 Nov 13, 2016
regexp.c patch 8.0.0074 Nov 10, 2016
regexp.h patch 7.4.2293 Aug 29, 2016
regexp_nfa.c patch 8.0.0165: ubsan warns for integer overflow Jan 10, 2017
screen.c
search.c
sha256.c patch 7.4.2293 Aug 29, 2016
spell.c patch 8.0.0074 Nov 10, 2016
spell.h patch 7.4.2293 Aug 29, 2016
spellfile.c patch 7.4.2293 Aug 29, 2016
structs.h Merge remote-tracking branch 'vim/master' Jan 15, 2017
swis.s updated for version 7.0001 Jun 13, 2004
syntax.c Merge remote-tracking branch 'vim/master' Jan 18, 2017
tag.c patch 8.0.0195: fail to jump to static tag in current file Jan 16, 2017
tearoff.bmp updated for version 7.0001 Jun 13, 2004
term.c
term.h patch 7.4.2293 Aug 29, 2016
termlib.c patch 7.4.2293 Aug 29, 2016
toolbar.phi updated for version 7.0001 Jun 13, 2004
toolcheck updated for version 7.0001 Jun 13, 2004
tools.bmp
typemap updated for version 7.3.439 Feb 11, 2012
ui.c Merge remote-tracking branch 'vim/master' Sep 30, 2016
undo.c Merge remote-tracking branch 'vim/master' Jan 18, 2017
uninstal.c patch 7.4.2293 Aug 29, 2016
userfunc.c
version.c Merge remote-tracking branch 'vim/master' Jan 18, 2017
version.h Vim 8.0 release Sep 12, 2016
vim.def
vim.h
vim.ico updated for version 7.0001 Jun 13, 2004
vim.rc patch 7.4.2293 Aug 29, 2016
vim.tlb updated for version 7.0001 Jun 13, 2004
vim_alert.ico updated for version 7.0001 Jun 13, 2004
vim_error.ico updated for version 7.0001 Jun 13, 2004
vim_icon.xbm updated for version 7.0001 Jun 13, 2004
vim_info.ico updated for version 7.0001 Jun 13, 2004
vim_mask.xbm updated for version 7.0001 Jun 13, 2004
vim_quest.ico updated for version 7.0001 Jun 13, 2004
vimio.h patch 7.4.2293 Aug 29, 2016
vimrun.c
vimtutor patch 8.0.0007 Sep 21, 2016
which.sh updated for version 7.0001 Jun 13, 2004
winclip.c patch 7.4.2293 Aug 29, 2016
window.c Merge remote-tracking branch 'vim/master' Nov 14, 2016
workshop.c patch 8.0.0012 Sep 25, 2016
workshop.h patch 7.4.2293 Aug 29, 2016
wsdebug.c patch 8.0.0012 Sep 25, 2016
wsdebug.h patch 7.4.2293 Aug 29, 2016
xpm_w32.c
xpm_w32.h patch 7.4.1200 Jan 29, 2016

README.txt

README for the Vim source code

Here are a few hints for finding your way around the source code.  This
doesn't make it less complex than it is, but it gets you started.

You might also want to read ":help development".


JUMPING AROUND

First of all, use ":make tags" to generate a tags file, so that you can use
the ":tag" command to jump around the source code.

To jump to a function or variable definition, move the cursor on the name and
use the CTRL-] command.  Use CTRL-T or CTRL-O to jump back.

To jump to a file, move the cursor on its name and use the "gf" command.

Most code can be found in a file with an obvious name (incomplete list):
	buffer.c	manipulating buffers (loaded files)
	diff.c		diff mode (vimdiff)
	eval.c		expression evaluation
	fileio.c	reading and writing files
	fold.c		folding
	getchar.c	getting characters and key mapping
	mark.c		marks
	mbyte.c		multi-byte character handling
	memfile.c	storing lines for buffers in a swapfile
	memline.c	storing lines for buffers in memory
	menu.c		menus
	message.c	(error) messages
	ops.c		handling operators ("d", "y", "p")
	option.c	options
	quickfix.c	quickfix commands (":make", ":cn")
	regexp.c	pattern matching
	screen.c	updating the windows
	search.c	pattern searching
	spell.c		spell checking
	syntax.c	syntax and other highlighting
	tag.c		tags
	term.c		terminal handling, termcap codes
	undo.c		undo and redo
	window.c	handling split windows


IMPORTANT VARIABLES

The current mode is stored in "State".  The values it can have are NORMAL,
INSERT, CMDLINE, and a few others.

The current window is "curwin".  The current buffer is "curbuf".  These point
to structures with the cursor position in the window, option values, the file
name, etc.  These are defined in structs.h.

All the global variables are declared in globals.h.


THE MAIN LOOP

This is conveniently called main_loop().  It updates a few things and then
calls normal_cmd() to process a command.  This returns when the command is
finished.

The basic idea is that Vim waits for the user to type a character and
processes it until another character is needed.  Thus there are several places
where Vim waits for a character to be typed.  The vgetc() function is used for
this.  It also handles mapping.

Updating the screen is mostly postponed until a command or a sequence of
commands has finished.  The work is done by update_screen(), which calls
win_update() for every window, which calls win_line() for every line.
See the start of screen.c for more explanations.


COMMAND-LINE MODE

When typing a ":", normal_cmd() will call getcmdline() to obtain a line with
an Ex command.  getcmdline() contains a loop that will handle each typed
character.  It returns when hitting <CR> or <Esc> or some other character that
ends the command line mode.


EX COMMANDS

Ex commands are handled by the function do_cmdline().  It does the generic
parsing of the ":" command line and calls do_one_cmd() for each separate
command.  It also takes care of while loops.

do_one_cmd() parses the range and generic arguments and puts them in the
exarg_t and passes it to the function that handles the command.

The ":" commands are listed in ex_cmds.h.  The third entry of each item is the
name of the function that handles the command.  The last entry are the flags
that are used for the command.


NORMAL MODE COMMANDS

The Normal mode commands are handled by the normal_cmd() function.  It also
handles the optional count and an extra character for some commands.  These
are passed in a cmdarg_t to the function that handles the command.

There is a table nv_cmds in normal.c which lists the first character of every
command.  The second entry of each item is the name of the function that
handles the command.


INSERT MODE COMMANDS

When doing an "i" or "a" command, normal_cmd() will call the edit() function.
It contains a loop that waits for the next character and handles it.  It
returns when leaving Insert mode.


OPTIONS

There is a list with all option names in option.c, called options[].


THE GUI

Most of the GUI code is implemented like it was a clever terminal.  Typing a
character, moving a scrollbar, clicking the mouse, etc. are all translated
into events which are written in the input buffer.  These are read by the
main code, just like reading from a terminal.  The code for this is scattered
through gui.c.  For example: gui_send_mouse_event() for a mouse click and
gui_menu_cb() for a menu action.  Key hits are handled by the system-specific
GUI code, which calls add_to_input_buf() to send the key code.

Updating the GUI window is done by writing codes in the output buffer, just
like writing to a terminal.  When the buffer gets full or is flushed,
gui_write() will parse the codes and draw the appropriate items.  Finally the
system-specific GUI code will be called to do the work.


DEBUGGING THE GUI

Remember to prevent that gvim forks and the debugger thinks Vim has exited,
add the "-f" argument.  In gdb: "run -f -g".

When stepping through display updating code, the focus event is triggered
when going from the debugger to Vim and back.  To avoid this, recompile with
some code in gui_focus_change() disabled.