LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   vi editor auto-completion (https://www.linuxquestions.org/questions/linux-software-2/vi-editor-auto-completion-914382/)

iamonly 11-19-2011 07:21 AM

vi editor auto-completion
 
Hi guys!
I am using ex-050325.tar.bz2 (traditional vi editor),
and complie it from source.
I want to accomplish auto-completion in this version of vi editor.
(e.g. by typing "gr<space>", the string "group" emerges on the screen.)
I did this by adding the following line to my ~/.exrc:
------------
ab gr group
------------
The problem is, I have some hundreds of such abbreviations to add.
However, I always get an "ERROR" when the number of lines of .exrc file
reach a certain limit.
Can anybody help me out? New ways of solution are always welcome!

Notice that I also use the command
-------------
so /root/mylist_of_abbreviations
-------------
in the editor to use /root/my...tions as a source read by vi,
and the same problem occurred:
there is a limit of number of lines for the sourced file...

PS: Please do not recommend another editor, though a newbie, I am
quite hard-nose on the traditional vi editor, and there is no reason
for changing only because of this little problem.
(everything perfectly feed my needs except this one)

davemguru 11-20-2011 04:35 AM

Would you consider "vim" to be "another editor"? It has all the "vi" facilities and much more facilities for "abbr" and mapping.

Alternatively - if you look at the source file "ex_tune.h" you will see
Code:

/*
 * Size of in-core buffers for temporary file. Since this is
 * sizeof (char) * (INCORB + 1) * BUFSIZ, it should not be too
 * large.
 *
 * If not defined, no in-core buffers are used.
 */
#ifdef  VMUNIX
#if    (BUFSIZ - 0) <= 16384
#define INCORB          (65536/BUFSIZ)
#else  /* Huge-memory systems. */
#define INCORB          4
#endif  /* Huge-memory systems. */
#endif  /* VMUNIX */

/*
 * Except on VMUNIX, these are a ridiculously small due to the
 * lousy arglist processing implementation which fixes core
 * proportional to them.  Argv (and hence NARGS) is really unnecessary,
 * and argument character space not needed except when
 * arguments exist.  Argument lists should be saved before the "zero"
 * of the incore line information and could then
 * be reasonably large.
 */

BUFSIZ is defined as 512 - therefore - (assuming VMUNIX is false) INCORB = 4 seems to be a limiting factor. Perhaps you could try undefining INCORB and see if "no in core buffers are used" will remove the limitations you are experiencing - OR instead of 4 for INCORB - try a factor of 10 bigger?

Dave

iamonly 11-20-2011 08:54 AM

davemguru, Thank you very much for your insightful reply!
I think I will try the ex_tune.h method as soon as possible.
Since I am not familiar with computer program languages (only a user of Linux), I have not consider the problem as far as you do...
I will finally post the result for my problem. :-)

iamonly 11-20-2011 10:38 PM

davemguru: hi, I tried out the two ways you propose *, but neither of them work.
A little pity. Maybe I shall try vim instead.
(* That is, undefine INCORB by comment out the whole section you posted and compile again, or change the line
-------
#define INCORB 4
-------
to
------
#define INCORB 9
------
and re-compile.)
Anyway, thank you for your time and effort.

iamonly 11-23-2011 08:38 AM

Hi, guys.
I finally find a fair solution myself.
After searching on the net a huge time, I learned that the traditional vi editor
has a limitation on the number of key maps in exrc file.
(It is designed to have this limitation!!)
http://publib.boulder.ibm.com/infoce...ixcmds6/vi.htm

I now switch to the editor nvi (new vi), it is great!
http://en.wikipedia.org/wiki/Nvi
https://sites.google.com/a/bostic.com/keithbostic/nvi

It retains the heritages of the traditional vi
(elegance, simplicity, ...) and removes the limitations of the traditional vi.
So now I can have hundreds of abbreviations defined in exrc.
I must say that, nvi perhaps is the simplest editor which possesses all the
powerful functions of triditional vi, yet free of the many limitations of it.


All times are GMT -5. The time now is 01:46 AM.