Search notes:

vim sources

The source files apparently are C99 compatible.
Functions that handle machine specific stuff seem to have the prefix mch_….
ascii.h
autocmd.c autocommands
buffer.c manipulating buffers (loaded files)
create_cmdidxs.vim Creates ex_cmdidxs.h
diff.c diff mode (vimdiff)
digraph.c digraphs
dosinst.c
drawline.c middle level for screen drawing/painting
drawscreen.c top level for screen drawing/painting
edit.c functions for insert mode
eval.c expression evaluation
evalfunc. Vim: built in functions[Built-in VIM functions.
ex_docmd.c Functions for executing an ex command line. (Function do_cmdline())
ex_cmds.h defines Vim: ex commands
ex_cmds.c some functions for command line commands
ex_cmds2.c Some more functions for command line commands.
ex_cmdidxs.h Automatically generated code by create_cmdidxs.vim.
ex_getln.c functions for entering and editing an Ex command line.
feature.h Definitions of preferences when vim is compiled.
filepath.c Dealing with filenames and paths.
fileio.c reading and writing files
findfile.c search for files in 'path'
fold.c Implement folding
getchar.c Functions related with getting a character from the user/mapping/redo/…
globals.h Definition of global variables.
gui.h
gui.c
gui_w32.c GUI support for Microsoft Windows, aka Win32.
indent.c C and Lisp indentation
keymap.h Keycode definitions for special keys (K_…)
map.c
mark.c functions for setting marks and jumping to them
mbyte.c multi-byte character handling
main.c defines main
memfile.c storing lines for buffers in a swapfile
memline.c storing lines for buffers in memory
menu.c menus
message.c Functions for displaying (error) messages on the command line.
misc1.c Functions that didn't seem to fit elsewhere
misc2.c Various functions
normal.c
ops.c handling operators (d, y, p, …)
option.c Code to handle user-settable options.
optiondefs.h option definitions
os_dos.h
os_mswin.c Routines for win32
os_w32dll.c
os_w32exe.c defines wWinMain which calls main which is defined in main.c.
patdef.sh
proto.h Include the (automatically generated) function prototypes.
quickfix.c quickfix commands (":make", ":cn")
regexp.h
regexp.c regular expressions
screen.c updating the windows (update_screen() calls win_update() for every window which calls win_line() for every line.
scriptfile.c Functions for dealing with the runtime directories/files.
search.c pattern searching
sign.c signs
spell.c spell checking
structs.h Definitions of structs used in vim
syntax.c Syntax and other highlighting.
tag.c tags
term.c terminal handling, termcap codes
terminal.c terminal window support
testing.c Support for tests
undo.c undo and redo
ui.c functions for the user interface: keyboard input, clipboard, input buffer
version.h
version.c
version.c
vim.h defines version number, name etc.
vimrun.c to create vimrun.exe.
vim.ico Icon
vim.rc Icon and version information for the Win32 version of Vim
vim.9 types and globals used for Vim9 script.
winclip.c Clipboard handling for Windows
window.c handling split windows
xpm_w32.c LoadXpmImage() which tries to load an XPM image from a file.
src/Make_cyg_ming.mak
auto/pathdef.c generated from pathdef.sh

Macros

BACKSLASH_IN_FILENAME
CASE_INSENSITIVE_FILENAME ignore case when comparing file names
CLEAN_RUNTIMEPATH
DFLT_BDIR Default backup directory (backupdir)
DFLT_DIR Default directory (directory)
DFLT_ERRORFILE
DFLT_RUNTIMEPATH Default runtimepath.
DFLT_VDIR Default view directory (viewdir)
DO_DECLARE_EXCMD Used in ex_cmds.h: if defined, a table with ex command names and options is generated, otherwise, an enum with all ex commands is generated. DO_DECLARE_EXCMD is defined in ex_docmd.c before it inlucde ex_cmds.h.
ELAPSED_FUNC
EVIM_FILE
EXRC_FILE
GVIMRC_FILE
DFLT_HELPFILE Specifies the default value for the option helpfile, defined in one of the os_….h files, for example in os_dos.h to "$VIMRUNTIME\\doc\\help.txt".
FILETYPE_FILE
FTOFF_FILE
FTPLUGIN_FILE
FTPLUGOF_FILE
GLOBAL_IME if defined vim_WindowProc() (= MyWindowProc) calls global_ime_DefWindowProc(), otherwise DefWindowProcW().
HAVE_DUP If dup() is available
HAVE_TRY_EXCEPT Used in Windows environment for __try and __except?
HAVE_ST_MODE if stat.st_mode is available
INDENT_FILE
INDOFF_FILE
MCH_WRITE_DUMP Record all output and all keyboard & mouse input (if compiled on Windows, see os_mswin32 and os_win32.c).
MSWIN
MSWIN_FIND_REPLACE
NO_CONSOLE_INPUT
PROTO
RUNTIME_DIRNAME Generic name for the directory of the runtime files, in src/feature.h assigned to the value "runtime".
SPACE_IN_FILENAME
SPECIAL_WILDCARD
SYNTAX_FNAME
SYS_GVIMRC_FILE See vimrc
SYS_MENU_FILE
SYS_OPTWIN_FILE
SYS_VIMRC_FILE See vimrc
UNIX
USE_CRNL If lines end in CR/NL rather than NL
USE_EXE_NAME if defined, vim - src/globals.h defines a global variable exe_name that stores the name of the executable.
USE_INPUT_BUF Use input buffer? USE_INPUT_BUF is defined if at least one of UNIX, FEAT_GUI, VMS or FEAT_CLIENTSERVER is defined (vim.h).
USR_EXRC_FILE
USR_EXRC_FILE2
USR_GVIMRC_FILE
USR_GVIMRC_FILE2
USR_GVIMRC_FILE3
USR_VIMRC_FILE See vimrc
USR_VIMRC_FILE2
USR_VIMRC_FILE3
VIM_BACKTICK
VIMDLL Experimental: if set to yes (src/Make_cyg_ming.mak), vim32.dll and/or(?) vim,64.dll is created along with a gvim.exe and/or(?) vim.exe stub. See also os_w32dll.c.
VIMINFO_FILE
VIMINFO_FILE2
VIM_DEFAULTS_FILE
VIM_VERSION_LONG used for :version
VIM_VERSION_MEDIUM Used for the startup-screen.
VIM_VERSION_NODOT Used for the runtime directory name, defined as "vim" VIM_VERSION_MAJOR_STR VIM_VERSION_MINOR_STR
VIM_VERSION_SHORT copied into the swap file, max length is 6 characters.
VIMRC_FILE
In a Windows environment, these macros might be defined in os_dos.h.
Compare with features that are also defined as macros.

Misc

Line/cursor numbering

Vim uses line and column numbers to refer to a position on a character (not between two characters).

TODO

Keyboard handling

CSI stands for control sequence introducer. Related macros seem to be CSI, CSI_STR, KS_CSI, KE_CSI, T_CSI (see also add_to_input_buf_csi() in ui.c).
The global variable mod_mask is set by vgetc() to the set of modifiers that are held down based on the MOD_MASK_… symboles that are read first.

Buffers

There seem to be some buffer types:
  • input buffer
  • stuff buffer (? A command that is translated into another command, like D -> d$, or to redo a command (.))
  • typeahead buffer (stores text that is already obtainexd but not yet used, and results of mappings, and is used for the :normal command. represented by a typebuf_T struct.
  • read buffer (compare stuff_inserted(), read_readbuffers())
  • redo buffer (? to redo the last change)
  • recording buffer (for the q command)
  • … ?
The contents of the stuff buffer and the mapped characters in the typeahead buffer is removed in the function flush_buffers().
Structs:
  • buffblock_T is used to store one block of the stuff/redo/recording buffers.
  • buffheader_T is used for the stuff buffer and the redo buffer.
  • typebuf_T is used for the typeahead buffer.
  • tasave_T holds the saved typeahead (for save_typeahead()).
The input buffer seems to be filled mainly with characters that are typed on a keyboard (see for example _OnChar in gui_w32.c.
As per two comments in gui.c (gui_send_mouse_event() and gui_drag_scrollbar()), the input buffer seems also able to store mouse events and scrollbar draging information.
typebuf.tb_buf (whose middle part has room for typeahead.
As per a comment in getchar.c (save_typeahead), there are three kinds of typeahead.
ins_typebuf() inserts a string into the typeahead buffer.
feedkeys() or server_to_input_buf() might insert characters into the typeahead buffer (while waiting for input to arrive).
ex_docmd.c has the interesting comment
Execute from the typeahead buffer.
Continue until the stuff buffer is empty and all added characters have been consumed.

Screen

There are three levels for screen drawing/painting, from top to bottom:
Global variables that are used in concjunction with the screen, defined in globals.h are
long Columns and Rows Number of columns/rows on the screen
char_u *ScreenLines Characters on the screen
u8char_T* ScreenLinesUC Decoded UTF-8 characters
unsigned short *ScreenAttrs These characters' attributes
unsigned *LineOffset
int screen_Rows and screen_columns actual size of ScreenLines
char_u LineWraps
u8char_T* ScreenLinesC Composing characters
char_u *current_ScreenLine Buffer for one screen line (? characters and attributres)
int screen_cur_row and screen_cur_col Last known cursor position, mostly used by windgoto() and screen_char()
match_T screen_search_hl used for hlsearch highlight matching
`foldinfo_T win_foldinfo info for foldcolumn

K_…

K_SPECIAL introduces a special key (in a buffer?) and is followed by two bytes.
A literal K_SPECIAL is stored as K_SPECIAL KS_SPECIAL KE_FILLER.

See also

src\README.txt, :help development
xxd/xxd.c
GvimExt/gvimext.cpp

Index