Mercurial > vim
diff src/eval.c @ 7480:a49163681559 v7.4.1042
commit https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 3 22:49:16 2016 +0100
patch 7.4.1042
Problem: g-CTRL-G shows the word count, but there is no way to get the word
count in a script.
Solution: Add the wordcount() function. (Christian Brabandt)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Jan 2016 23:00:04 +0100 |
parents | e583db6c4fd4 |
children | 3fcd3d235f7b |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -780,6 +780,7 @@ static void f_winrestview __ARGS((typval static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv)); static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv)); static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_wordcount __ARGS((typval_T *argvars, typval_T *rettv)); static void f_xor __ARGS((typval_T *argvars, typval_T *rettv)); static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp)); @@ -8387,6 +8388,7 @@ static struct fst {"winrestview", 1, 1, f_winrestview}, {"winsaveview", 0, 0, f_winsaveview}, {"winwidth", 1, 1, f_winwidth}, + {"wordcount", 0, 0, f_wordcount}, {"writefile", 2, 3, f_writefile}, {"xor", 2, 2, f_xor}, }; @@ -20220,6 +20222,19 @@ f_winwidth(argvars, rettv) } /* + * "wordcount()" function + */ + static void +f_wordcount(argvars, rettv) + typval_T *argvars UNUSED; + typval_T *rettv; +{ + if (rettv_dict_alloc(rettv) == FAIL) + return; + cursor_pos_info(rettv->vval.v_dict); +} + +/* * Write list of strings to file */ static int