Data Structures | Macros | Enumerations | Functions
ex_cmds.c File Reference
#include <assert.h>
#include <float.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>
#include "nvim/api/private/defs.h"
#include "nvim/api/buffer.h"
#include "nvim/log.h"
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/ex_cmds.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
#include "nvim/digraph.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
#include "nvim/highlight.h"
#include "nvim/indent.h"
#include "nvim/buffer_updates.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/garray.h"
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/mouse.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/spell.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
#include "nvim/os/input.h"
#include "nvim/os/time.h"

Data Structures

struct  subflags_T
 Flags kept between calls to :substitute. More...
 
struct  SubResult
 
struct  PreviewLines
 
struct  sorti_T
 Struct to store info to be sorted. More...
 

Macros

#define SPACE_FOR_DESC   (1 + 1 + 1 + MB_MAXBYTES + 16 + 4 + 3 + 3 + 1)
 
#define ADJUST_SUB_FIRSTLNUM()
 
#define PUSH_PREVIEW_LINES()
 

Enumerations

enum  SubIgnoreType { kSubHonorOptions = 0, kSubIgnoreCase, kSubMatchCase }
 Case matching style to use for :substitute. More...
 

Functions

void do_ascii (const exarg_T *const eap)
 ":ascii" and "ga" implementation More...
 
void ex_align (exarg_T *eap)
 
void ex_sort (exarg_T *eap)
 
void ex_retab (exarg_T *eap)
 
int do_move (linenr_T line1, linenr_T line2, linenr_T dest)
 
void ex_copy (linenr_T line1, linenr_T line2, linenr_T n)
 
void do_bang (int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
 
void do_shell (char_u *cmd, int flags)
 
char_umake_filter_cmd (char_u *cmd, char_u *itmp, char_u *otmp)
 
void append_redir (char *const buf, const size_t buflen, const char *const opt, const char *const fname)
 
void print_line_no_prefix (linenr_T lnum, int use_number, int list)
 
void print_line (linenr_T lnum, int use_number, int list)
 
int rename_buffer (char_u *new_fname)
 
void ex_file (exarg_T *eap)
 
void ex_update (exarg_T *eap)
 
void ex_write (exarg_T *eap)
 
int do_write (exarg_T *eap)
 
int check_overwrite (exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other)
 
void ex_wnext (exarg_T *eap)
 
void do_wqall (exarg_T *eap)
 
int not_writing (void)
 
int getfile (int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit)
 
int do_ecmd (int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags, win_T *oldwin)
 
void ex_append (exarg_T *eap)
 
void ex_change (exarg_T *eap)
 
void ex_z (exarg_T *eap)
 
int check_restricted (void)
 
int check_secure (void)
 
void sub_get_replacement (SubReplacementString *const ret_sub) FUNC_ATTR_NONNULL_ALL
 
void sub_set_replacement (SubReplacementString sub)
 
bool do_sub_msg (bool count_only)
 
void ex_global (exarg_T *eap)
 
void global_exe (char_u *cmd)
 Execute cmd on lines marked with ml_setmarked(). More...
 
bool prepare_tagpreview (bool undo_sync)
 
void ex_help (exarg_T *eap)
 
char_ucheck_help_lang (char_u *arg)
 
int help_heuristic (char_u *matched_string, int offset, int wrong_case)
 
int find_help_tags (const char_u *arg, int *num_matches, char_u ***matches, bool keep_lang)
 
void fix_help_buffer (void)
 
void ex_exusage (exarg_T *eap)
 
void ex_viusage (exarg_T *eap)
 
void ex_helptags (exarg_T *eap)
 
void ex_helpclose (exarg_T *eap)
 
void ex_substitute (exarg_T *eap)
 
char_uskip_vimgrep_pat (char_u *p, char_u **s, int *flags)
 
void ex_oldfiles (exarg_T *eap)
 List v:oldfiles in a nice way. More...
 

Macro Definition Documentation

#define ADJUST_SUB_FIRSTLNUM ( )
Value:
do { \
/* For a multi-line match, make a copy of the last matched */ \
/* line and continue in that one. */ \
if (nmatch > 1) { \
sub_firstlnum += nmatch - 1; \
xfree(sub_firstline); \
sub_firstline = vim_strsave(ml_get(sub_firstlnum)); \
/* When going beyond the last line, stop substituting. */ \
if (sub_firstlnum <= line2) { \
do_again = true; \
} else { \
subflags.do_all = false; \
} \
} \
if (skip_match) { \
/* Already hit end of the buffer, sub_firstlnum is one */ \
/* less than what it ought to be. */ \
xfree(sub_firstline); \
sub_firstline = vim_strsave((char_u *)""); \
copycol = 0; \
} \
} while (0)
char_u * ml_get(linenr_T lnum)
Definition: memline.c:1793
if(len)
Definition: encode.c:222
char_u * vim_strsave(const char_u *string) FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
Copy "string" into newly allocated memory.
Definition: strings.c:55
unsigned char char_u
Definition: types.h:11
xfree(sourcing_name)
#define PUSH_PREVIEW_LINES ( )
Value:
do { \
linenr_T match_lines = current_match.end.lnum \
- current_match.start.lnum +1; \
if (preview_lines.subresults.size > 0) { \
linenr_T last = kv_last(preview_lines.subresults).end.lnum; \
if (last == current_match.start.lnum) { \
preview_lines.lines_needed += match_lines - 1; \
} \
} else { \
preview_lines.lines_needed += match_lines; \
} \
kv_push(preview_lines.subresults, current_match); \
} while (0)
if(len)
Definition: encode.c:222
#define kv_push(v, x)
Definition: kvec.h:101
long linenr_T
Definition: pos.h:4
#define kv_last(v)
Definition: kvec.h:71
#define SPACE_FOR_DESC   (1 + 1 + 1 + MB_MAXBYTES + 16 + 4 + 3 + 3 + 1)

Enumeration Type Documentation

Case matching style to use for :substitute.

Enumerator
kSubHonorOptions 

Honor the user's 'ignorecase'/'smartcase' options.

kSubIgnoreCase 

Ignore case of the search.

kSubMatchCase 

Match case of the search.

Function Documentation

void append_redir ( char *const  buf,
const size_t  buflen,
const char *const  opt,
const char *const  fname 
)

Append output redirection for the given file to the end of the buffer

Parameters
[out]bufBuffer to append to.
[in]buflenBuffer length.
[in]optSeparator or format string to append: will append `printf(' ' . opt, fname)ifsis found inoptor a space, opt, a space and then fname ifs` is not found there.
[in]fnameFile name to append.
char_u* check_help_lang ( char_u arg)
int check_overwrite ( exarg_T eap,
buf_T buf,
char_u fname,
char_u ffname,
int  other 
)
int check_restricted ( void  )
int check_secure ( void  )
void do_ascii ( const exarg_T *const  eap)

":ascii" and "ga" implementation

void do_bang ( int  addr_count,
exarg_T eap,
int  forceit,
int  do_in,
int  do_out 
)
int do_ecmd ( int  fnum,
char_u ffname,
char_u sfname,
exarg_T eap,
linenr_T  newlnum,
int  flags,
win_T oldwin 
)

start editing a new file

Parameters
fnumfile number; if zero use ffname/sfname
ffnamethe file name
  • full path if sfname used,
  • any file name if sfname is NULL
  • empty string to re-edit with the same file name (but may be in a different directory)
  • NULL to start an empty buffer
sfnamethe short file name (or NULL)
eapcontains the command to be executed after loading the file and forced 'ff' and 'fenc'
newlnumif > 0: put cursor on this line number (if possible) ECMD_LASTL: use last position in loaded file ECMD_LAST: use last position in all files ECMD_ONE: use first line
flagsECMD_HIDE: if TRUE don't free the current buffer ECMD_SET_HELP: set b_help flag of (new) buffer before opening file ECMD_OLDBUF: use existing buffer if it exists ECMD_FORCEIT: ! used for Ex command ECMD_ADDBUF: don't edit, just add to buffer list
oldwinShould be "curwin" when editing a new buffer in the current window, NULL when splitting the window first. When not NULL info of the previous buffer for "oldwin" is stored.
Returns
FAIL for failure, OK otherwise
int do_move ( linenr_T  line1,
linenr_T  line2,
linenr_T  dest 
)
void do_shell ( char_u cmd,
int  flags 
)
bool do_sub_msg ( bool  count_only)
void do_wqall ( exarg_T eap)
int do_write ( exarg_T eap)
void ex_align ( exarg_T eap)
void ex_append ( exarg_T eap)
void ex_change ( exarg_T eap)
void ex_copy ( linenr_T  line1,
linenr_T  line2,
linenr_T  n 
)
void ex_exusage ( exarg_T eap)
void ex_file ( exarg_T eap)
void ex_global ( exarg_T eap)
void ex_help ( exarg_T eap)
void ex_helpclose ( exarg_T eap)
void ex_helptags ( exarg_T eap)
void ex_oldfiles ( exarg_T eap)

List v:oldfiles in a nice way.

void ex_retab ( exarg_T eap)
void ex_sort ( exarg_T eap)
void ex_substitute ( exarg_T eap)

:substitute command

If 'inccommand' is empty: calls do_sub(). If 'inccommand' is set: shows a "live" preview then removes the changes. from undo history.

void ex_update ( exarg_T eap)
void ex_viusage ( exarg_T eap)
void ex_wnext ( exarg_T eap)
void ex_write ( exarg_T eap)
void ex_z ( exarg_T eap)
int find_help_tags ( const char_u arg,
int *  num_matches,
char_u ***  matches,
bool  keep_lang 
)
void fix_help_buffer ( void  )
int getfile ( int  fnum,
char_u ffname,
char_u sfname,
int  setpm,
linenr_T  lnum,
int  forceit 
)
void global_exe ( char_u cmd)

Execute cmd on lines marked with ml_setmarked().

int help_heuristic ( char_u matched_string,
int  offset,
int  wrong_case 
)
char_u* make_filter_cmd ( char_u cmd,
char_u itmp,
char_u otmp 
)

Create a shell command from a command string, input redirection file and output redirection file.

Parameters
cmdCommand to execute.
itmpNULL or the input file.
otmpNULL or the output file.
Returns
an allocated string with the shell command.
int not_writing ( void  )
bool prepare_tagpreview ( bool  undo_sync)
void print_line ( linenr_T  lnum,
int  use_number,
int  list 
)
void print_line_no_prefix ( linenr_T  lnum,
int  use_number,
int  list 
)
int rename_buffer ( char_u new_fname)
char_u* skip_vimgrep_pat ( char_u p,
char_u **  s,
int *  flags 
)

Skip over the pattern argument of ":vimgrep /pat/[g][j]". Put the start of the pattern in "*s", unless "s" is NULL. If "flags" is not NULL put the flags in it: VGR_GLOBAL, VGR_NOJUMP. If "s" is not NULL terminate the pattern with a NUL. Return a pointer to the char just past the pattern plus flags.

void sub_get_replacement ( SubReplacementString *const  ret_sub)

Get old substitute replacement string

Parameters
[out]ret_subLocation where old string will be saved.
void sub_set_replacement ( SubReplacementString  sub)

Set substitute string and timestamp

Warning
sub must be in allocated memory. It is not copied.
Parameters
[in]subNew replacement string.