struct file_buffer
{
    memline_T	b_ml;		/* associated memline (also contains line
				   count) */

    buf_T	*b_next;	/* links in list of buffers */
    buf_T	*b_prev;

    int		b_nwindows;	/* nr of windows open on this buffer */

    int		b_flags;	/* various BF_ flags */
#ifdef FEAT_AUTOCMD
    int		b_locked;	/* Buffer is being closed or referenced, don't
				   let autocommands wipe it out. */
#endif

    /*
     * b_ffname has the full path of the file (NULL for no name).
     * b_sfname is the name as the user typed it (or NULL).
     * b_fname is the same as b_sfname, unless ":cd" has been done,
     *		then it is the same as b_ffname (NULL for no name).
     */
    char_u	*b_ffname;	/* full path file name */
    char_u	*b_sfname;	/* short file name */
    char_u	*b_fname;	/* current file name */

#ifdef UNIX
    int		b_dev_valid;	/* TRUE when b_dev has a valid number */
    dev_t	b_dev;		/* device number */
    ino_t	b_ino;		/* inode number */
#endif
#ifdef FEAT_CW_EDITOR
    FSSpec	b_FSSpec;	/* MacOS File Identification */
#endif
#ifdef VMS
    char	 b_fab_rfm;	/* Record format    */
    char	 b_fab_rat;	/* Record attribute */
    unsigned int b_fab_mrs;	/* Max record size  */
#endif
    int		b_fnum;		/* buffer number for this file. */
    char_u	b_key[VIM_SIZEOF_INT * 2 + 1];
				/* key used for buf_hashtab, holds b_fnum as
				   hex string */

    int		b_changed;	/* 'modified': Set to TRUE if something in the
				   file has been changed and not written out. */
    dictitem16_T b_ct_di;	/* holds the b:changedtick value in
				   b_ct_di.di_tv.vval.v_number;
				   incremented for each change, also for undo */
#define CHANGEDTICK(buf) ((buf)->b_ct_di.di_tv.vval.v_number)

    int		b_saving;	/* Set to TRUE if we are in the middle of
				   saving the buffer. */

    /*
     * Changes to a buffer require updating of the display.  To minimize the
     * work, remember changes made and update everything at once.
     */
    int		b_mod_set;	/* TRUE when there are changes since the last
				   time the display was updated */
    linenr_T	b_mod_top;	/* topmost lnum that was changed */
    linenr_T	b_mod_bot;	/* lnum below last changed line, AFTER the
				   change */
    long	b_mod_xlines;	/* number of extra buffer lines inserted;
				   negative when lines were deleted */

    wininfo_T	*b_wininfo;	/* list of last used info for each window */

    long	b_mtime;	/* last change time of original file */
    long	b_mtime_read;	/* last change time when reading */
    off_T	b_orig_size;	/* size of original file in bytes */
    int		b_orig_mode;	/* mode of original file */
#ifdef FEAT_VIMINFO
    time_T	b_last_used;	/* time when the buffer was last used; used
				 * for viminfo */
#endif

    pos_T	b_namedm[NMARKS]; /* current named marks (mark.c) */

    /* These variables are set when VIsual_active becomes FALSE */
    visualinfo_T b_visual;
#ifdef FEAT_EVAL
    int		b_visual_mode_eval;  /* b_visual.vi_mode for visualmode() */
#endif

    pos_T	b_last_cursor;	/* cursor position when last unloading this
				   buffer */
    pos_T	b_last_insert;	/* where Insert mode was left */
    pos_T	b_last_change;	/* position of last change: '. mark */

#ifdef FEAT_JUMPLIST
    /*
     * the changelist contains old change positions
     */
    pos_T	b_changelist[JUMPLISTSIZE];
    int		b_changelistlen;	/* number of active entries */
    int		b_new_change;		/* set by u_savecommon() */
#endif

    /*
     * Character table, only used in charset.c for 'iskeyword'
     * 32 bytes of 8 bits: 1 bit per character 0-255.
     */
    char_u	b_chartab[32];

#ifdef FEAT_LOCALMAP
    /* Table used for mappings local to a buffer. */
    mapblock_T	*(b_maphash[256]);

    /* First abbreviation local to a buffer. */
    mapblock_T	*b_first_abbr;
#endif
#ifdef FEAT_USR_CMDS
    /* User commands local to the buffer. */
    garray_T	b_ucmds;
#endif
    /*
     * start and end of an operator, also used for '[ and ']
     */
    pos_T	b_op_start;
    pos_T	b_op_start_orig;  /* used for Insstart_orig */
    pos_T	b_op_end;

#ifdef FEAT_VIMINFO
    int		b_marks_read;	/* Have we read viminfo marks yet? */
#endif

    /*
     * The following only used in undo.c.
     */
    u_header_T	*b_u_oldhead;	/* pointer to oldest header */
    u_header_T	*b_u_newhead;	/* pointer to newest header; may not be valid
				   if b_u_curhead is not NULL */
    u_header_T	*b_u_curhead;	/* pointer to current header */
    int		b_u_numhead;	/* current number of headers */
    int		b_u_synced;	/* entry lists are synced */
    long	b_u_seq_last;	/* last used undo sequence number */
    long	b_u_save_nr_last; /* counter for last file write */
    long	b_u_seq_cur;	/* hu_seq of header below which we are now */
    time_T	b_u_time_cur;	/* uh_time of header below which we are now */
    long	b_u_save_nr_cur; /* file write nr after which we are now */

    /*
     * variables for "U" command in undo.c
     */
    char_u	*b_u_line_ptr;	/* saved line for "U" command */
    linenr_T	b_u_line_lnum;	/* line number of line in u_line */
    colnr_T	b_u_line_colnr;	/* optional column number */

#ifdef FEAT_INS_EXPAND
    int		b_scanned;	/* ^N/^P have scanned this buffer */
#endif

    /* flags for use of ":lmap" and IM control */
    long	b_p_iminsert;	/* input mode for insert */
    long	b_p_imsearch;	/* input mode for search */
#define B_IMODE_USE_INSERT -1	/*	Use b_p_iminsert value for search */
#define B_IMODE_NONE 0		/*	Input via none */
#define B_IMODE_LMAP 1		/*	Input via langmap */
#ifndef USE_IM_CONTROL
# define B_IMODE_LAST 1
#else
# define B_IMODE_IM 2		/*	Input via input method */
# define B_IMODE_LAST 2
#endif

#ifdef FEAT_KEYMAP
    short	b_kmap_state;	/* using "lmap" mappings */
# define KEYMAP_INIT	1	/* 'keymap' was set, call keymap_init() */
# define KEYMAP_LOADED	2	/* 'keymap' mappings have been loaded */
    garray_T	b_kmap_ga;	/* the keymap table */
#endif

    /*
     * Options local to a buffer.
     * They are here because their value depends on the type of file
     * or contents of the file being edited.
     */
    int		b_p_initialized;	/* set when options initialized */

#ifdef FEAT_EVAL
    int		b_p_scriptID[BV_COUNT];	/* SIDs for buffer-local options */
#endif

    int		b_p_ai;		/* 'autoindent' */
    int		b_p_ai_nopaste;	/* b_p_ai saved for paste mode */
    char_u	*b_p_bkc;	/* 'backupcopy' */
    unsigned	b_bkc_flags;    /* flags for 'backupcopy' */
    int		b_p_ci;		/* 'copyindent' */
    int		b_p_bin;	/* 'binary' */
#ifdef FEAT_MBYTE
    int		b_p_bomb;	/* 'bomb' */
#endif
#ifdef FEAT_QUICKFIX
    char_u	*b_p_bh;	/* 'bufhidden' */
    char_u	*b_p_bt;	/* 'buftype' */
#define BUF_HAS_QF_ENTRY 1
#define BUF_HAS_LL_ENTRY 2
    int		b_has_qf_entry;
#endif
    int		b_p_bl;		/* 'buflisted' */
#ifdef FEAT_CINDENT
    int		b_p_cin;	/* 'cindent' */
    char_u	*b_p_cino;	/* 'cinoptions' */
    char_u	*b_p_cink;	/* 'cinkeys' */
#endif
#if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
    char_u	*b_p_cinw;	/* 'cinwords' */
#endif
#ifdef FEAT_COMMENTS
    char_u	*b_p_com;	/* 'comments' */
#endif
#ifdef FEAT_FOLDING
    char_u	*b_p_cms;	/* 'commentstring' */
#endif
#ifdef FEAT_INS_EXPAND
    char_u	*b_p_cpt;	/* 'complete' */
#endif
#ifdef FEAT_COMPL_FUNC
    char_u	*b_p_cfu;	/* 'completefunc' */
    char_u	*b_p_ofu;	/* 'omnifunc' */
#endif
    int		b_p_eol;	/* 'endofline' */
    int		b_p_fixeol;	/* 'fixendofline' */
    int		b_p_et;		/* 'expandtab' */
    int		b_p_et_nobin;	/* b_p_et saved for binary mode */
    int	        b_p_et_nopaste; /* b_p_et saved for paste mode */
#ifdef FEAT_MBYTE
    char_u	*b_p_fenc;	/* 'fileencoding' */
#endif
    char_u	*b_p_ff;	/* 'fileformat' */
#ifdef FEAT_AUTOCMD
    char_u	*b_p_ft;	/* 'filetype' */
#endif
    char_u	*b_p_fo;	/* 'formatoptions' */
    char_u	*b_p_flp;	/* 'formatlistpat' */
    int		b_p_inf;	/* 'infercase' */
    char_u	*b_p_isk;	/* 'iskeyword' */
#ifdef FEAT_FIND_ID
    char_u	*b_p_def;	/* 'define' local value */
    char_u	*b_p_inc;	/* 'include' */
# ifdef FEAT_EVAL
    char_u	*b_p_inex;	/* 'includeexpr' */
    long_u	b_p_inex_flags;	/* flags for 'includeexpr' */
# endif
#endif
#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
    char_u	*b_p_inde;	/* 'indentexpr' */
    long_u	b_p_inde_flags;	/* flags for 'indentexpr' */
    char_u	*b_p_indk;	/* 'indentkeys' */
#endif
    char_u	*b_p_fp;	/* 'formatprg' */
#if defined(FEAT_EVAL)
    char_u	*b_p_fex;	/* 'formatexpr' */
    long_u	b_p_fex_flags;	/* flags for 'formatexpr' */
#endif
#ifdef FEAT_CRYPT
    char_u	*b_p_key;	/* 'key' */
#endif
    char_u	*b_p_kp;	/* 'keywordprg' */
#ifdef FEAT_LISP
    int		b_p_lisp;	/* 'lisp' */
#endif
#ifdef FEAT_MBYTE
    char_u	*b_p_menc;	/* 'makeencoding' */
#endif
    char_u	*b_p_mps;	/* 'matchpairs' */
    int		b_p_ml;		/* 'modeline' */
    int		b_p_ml_nobin;	/* b_p_ml saved for binary mode */
    int		b_p_ma;		/* 'modifiable' */
    char_u	*b_p_nf;	/* 'nrformats' */
    int		b_p_pi;		/* 'preserveindent' */
#ifdef FEAT_TEXTOBJ
    char_u	*b_p_qe;	/* 'quoteescape' */
#endif
    int		b_p_ro;		/* 'readonly' */
    long	b_p_sw;		/* 'shiftwidth' */
    int		b_p_sn;		/* 'shortname' */
#ifdef FEAT_SMARTINDENT
    int		b_p_si;		/* 'smartindent' */
#endif
    long	b_p_sts;	/* 'softtabstop' */
    long	b_p_sts_nopaste; /* b_p_sts saved for paste mode */
#ifdef FEAT_SEARCHPATH
    char_u	*b_p_sua;	/* 'suffixesadd' */
#endif
    int		b_p_swf;	/* 'swapfile' */
#ifdef FEAT_SYN_HL
    long	b_p_smc;	/* 'synmaxcol' */
    char_u	*b_p_syn;	/* 'syntax' */
#endif
    long	b_p_ts;		/* 'tabstop' */
    int		b_p_tx;		/* 'textmode' */
    long	b_p_tw;		/* 'textwidth' */
    long	b_p_tw_nobin;	/* b_p_tw saved for binary mode */
    long	b_p_tw_nopaste;	/* b_p_tw saved for paste mode */
    long	b_p_wm;		/* 'wrapmargin' */
    long	b_p_wm_nobin;	/* b_p_wm saved for binary mode */
    long	b_p_wm_nopaste;	/* b_p_wm saved for paste mode */
#ifdef FEAT_KEYMAP
    char_u	*b_p_keymap;	/* 'keymap' */
#endif

    /* local values for options which are normally global */
#ifdef FEAT_QUICKFIX
    char_u	*b_p_gp;	/* 'grepprg' local value */
    char_u	*b_p_mp;	/* 'makeprg' local value */
    char_u	*b_p_efm;	/* 'errorformat' local value */
#endif
    char_u	*b_p_ep;	/* 'equalprg' local value */
    char_u	*b_p_path;	/* 'path' local value */
    int		b_p_ar;		/* 'autoread' local value */
    char_u	*b_p_tags;	/* 'tags' local value */
    char_u	*b_p_tc;	/* 'tagcase' local value */
    unsigned	b_tc_flags;     /* flags for 'tagcase' */
#ifdef FEAT_INS_EXPAND
    char_u	*b_p_dict;	/* 'dictionary' local value */
    char_u	*b_p_tsr;	/* 'thesaurus' local value */
#endif
    long	b_p_ul;		/* 'undolevels' local value */
#ifdef FEAT_PERSISTENT_UNDO
    int		b_p_udf;	/* 'undofile' */
#endif
#ifdef FEAT_LISP
    char_u	*b_p_lw;	/* 'lispwords' local value */
#endif

    /* end of buffer options */

#ifdef FEAT_CINDENT
    /* values set from b_p_cino */
    int		b_ind_level;
    int		b_ind_open_imag;
    int		b_ind_no_brace;
    int		b_ind_first_open;
    int		b_ind_open_extra;
    int		b_ind_close_extra;
    int		b_ind_open_left_imag;
    int		b_ind_jump_label;
    int		b_ind_case;
    int		b_ind_case_code;
    int		b_ind_case_break;
    int		b_ind_param;
    int		b_ind_func_type;
    int		b_ind_comment;
    int		b_ind_in_comment;
    int		b_ind_in_comment2;
    int		b_ind_cpp_baseclass;
    int		b_ind_continuation;
    int		b_ind_unclosed;
    int		b_ind_unclosed2;
    int		b_ind_unclosed_noignore;
    int		b_ind_unclosed_wrapped;
    int		b_ind_unclosed_whiteok;
    int		b_ind_matching_paren;
    int		b_ind_paren_prev;
    int		b_ind_maxparen;
    int		b_ind_maxcomment;
    int		b_ind_scopedecl;
    int		b_ind_scopedecl_code;
    int		b_ind_java;
    int		b_ind_js;
    int		b_ind_keep_case_label;
    int		b_ind_hash_comment;
    int		b_ind_cpp_namespace;
    int		b_ind_if_for_while;
    int		b_ind_cpp_extern_c;
#endif

    linenr_T	b_no_eol_lnum;	/* non-zero lnum when last line of next binary
				 * write should not have an end-of-line */

    int		b_start_eol;	/* last line had eol when it was read */
    int		b_start_ffc;	/* first char of 'ff' when edit started */
#ifdef FEAT_MBYTE
    char_u	*b_start_fenc;	/* 'fileencoding' when edit started or NULL */
    int		b_bad_char;	/* "++bad=" argument when edit started or 0 */
    int		b_start_bomb;	/* 'bomb' when it was read */
#endif

#ifdef FEAT_EVAL
    dictitem_T	b_bufvar;	/* variable for "b:" Dictionary */
    dict_T	*b_vars;	/* internal variables, local to buffer */
#endif

#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
    char_u	*b_p_bexpr;	/* 'balloonexpr' local value */
    long_u	b_p_bexpr_flags;/* flags for 'balloonexpr' */
#endif
#ifdef FEAT_CRYPT
    char_u	*b_p_cm;	/* 'cryptmethod' */
#endif

    /* When a buffer is created, it starts without a swap file.  b_may_swap is
     * then set to indicate that a swap file may be opened later.  It is reset
     * if a swap file could not be opened.
     */
    int		b_may_swap;
    int		b_did_warn;	/* Set to 1 if user has been warned on first
				   change of a read-only file */

    /* Two special kinds of buffers:
     * help buffer  - used for help files, won't use a swap file.
     * spell buffer - used for spell info, never displayed and doesn't have a
     *		      file name.
     */
    int		b_help;		/* TRUE for help file buffer (when set b_p_bt
				   is "help") */
#ifdef FEAT_SPELL
    int		b_spell;	/* TRUE for a spell file buffer, most fields
				   are not used!  Use the B_SPELL macro to
				   access b_spell without #ifdef. */
#endif

    int		b_shortname;	/* this file has an 8.3 file name */

#ifdef FEAT_MZSCHEME
    void	*b_mzscheme_ref; /* The MzScheme reference to this buffer */
#endif

#ifdef FEAT_PERL
    void	*b_perl_private;
#endif

#ifdef FEAT_PYTHON
    void	*b_python_ref;	/* The Python reference to this buffer */
#endif

#ifdef FEAT_PYTHON3
    void	*b_python3_ref;	/* The Python3 reference to this buffer */
#endif

#ifdef FEAT_TCL
    void	*b_tcl_ref;
#endif

#ifdef FEAT_RUBY
    void	*b_ruby_ref;
#endif

#if defined(FEAT_SYN_HL) || defined(FEAT_SPELL)
    synblock_T	b_s;		/* Info related to syntax highlighting.  w_s
				 * normally points to this, but some windows
				 * may use a different synblock_T. */
#endif

#ifdef FEAT_SIGNS
    signlist_T	*b_signlist;	/* list of signs to draw */
# ifdef FEAT_NETBEANS_INTG
    int		b_has_sign_column; /* Flag that is set when a first sign is
				    * added and remains set until the end of
				    * the netbeans session. */
# endif
#endif

#ifdef FEAT_NETBEANS_INTG
    int		b_netbeans_file;    /* TRUE when buffer is owned by NetBeans */
    int		b_was_netbeans_file;/* TRUE if b_netbeans_file was once set */
#endif
#ifdef FEAT_JOB_CHANNEL
    int		b_write_to_channel; /* TRUE when appended lines are written to
				     * a channel. */
#endif

#ifdef FEAT_CRYPT
    cryptstate_T *b_cryptstate;	/* Encryption state while reading or writing
				 * the file. NULL when not using encryption. */
#endif
    int		b_mapped_ctrl_c; /* modes where CTRL-C is mapped */

}; /* file_buffer */
