Search notes:

vim - src/globals.h

globals.h contains the definition of global variables.

The EXTERN macro

These global variables are prefixed with the macro EXTERN, for example
EXTERN schar_T	*ScreenLines INIT(= NULL);
The main.c defines EXTERN before it includes vim.h which in turn includes globals.h.
Thus, when main.c is compiled, the global variables are defined.
However, globals.h also contains
#ifndef EXTERN
# define EXTERN extern
# define INIT(x)
#else
# ifndef INIT
#  define INIT(x) x
#  define DO_INIT
   …
# endif
#endif
This allows to externally declare all global variables for all other compilation units.

State

State stores vim's currently active mode. Values that can be assigned to State (such as NORMAL etc.) are defined in vim.h.
EXTERN int	State INIT(= NORMAL);

homedir

homedir stores the value of $HOME (if no environment variable with the name HOME exists), see init_homedir().

got_int

got_int is set to TRUE when an interrupt signal was caught.

Windows (win_T) strucures

Vim stores the characteristics of windows in win_T structures.
Regular (that is non-hidden (?)) windows] are stored in a linked list.
*firstwin points to its first entry, *curwin to the current window, *lastwin to the last entry in the linked list.

Buffer related

Linked list of buffers

All buffers are stored in a linked list.
The global variables firstbuf and lastbuf, whose type is buf_T* point to the first and last buffer, respectively, in the linked list.

FOR_ALL_BUFFERS

FOR_ALL_BUFFERS is a macro that iterates over all buffers in the linked list. It is defined as
#define FOR_ALL_BUFFERS(buf) for (buf = firstbuf; buf != NULL; buf = buf->b_next)

curbuf

The global variable curbuf, whose type is also buf_T* points to the currently active buffer.

cmdline window related

#ifdef FEAT_CMDWIN
EXTERN int	cmdwin_type INIT(= 0);	// type of cmdline window or 0
EXTERN int	cmdwin_result INIT(= 0); // result of cmdline window or 0
#endif
cmdwin_result is used in main_loop() as a terminating condition to break out from the main loop if the main loop is used to input command line data.

Variables that are defined in pathdef.c

Some variables are defined in src/auto/pathdef.c (which is generated during the make process):
extern char_u *default_vim_dir;           // Location of the global vimrc file    (for example /etc, set with the make option VIMRCLOC)
extern char_u *default_vimruntime_dir;    // Location of the global runtime files (for example /usr/share/vim, set with the make option VIMRUNTIMEDIR)
extern char_u *all_cflags;                // compiler options with which vim sources were compiled.
extern char_u *all_lflags;                // linker options with which vim was linked.
extern char_u *compiled_user;
extern char_u *compiled_sys;

misc

exe_name

exe_name is present if the macro USE_EXE_NAME is defined. It stores the name of the executable.
The value of exe_name might be used to determine the value of $VIM.
The value of exe_name is determined in get_exe_name()

didset_vim / didset_vimruntime

The values of didset_vim and didset_vimruntime indicate if vim has set the values of $VIM and $VIMRUNTIME, respectively, has been set.

stop_insert_mode

EXTERN int	stop_insert_mode;	// for ":stopinsert" and 'insertmode'
stop_insert_mode is set to TRUE (amon others) with :stopinsert
Queried in edit.c

TODO


Index