Structure and Interpretation of Vim - mparm_T

Before analyzing how to initialize vim, I'll give you a brief description of mparm_T.

The mparm_T is used for sharing several parameters with the main function and other functions for initializing. This struct reduces complexity of passing parameters. But it is just wrapper, not organized well, so comprehending it without prior knowledge is little hard.

I'll explain the parameters in mparm_T one by one.

1. argc, argv

These are copy of argc and argv of main function. The other parameters are initialized according to argv.

2. evim_mode

Run with "-y" option or run by evim command, start as the easy vim. The easy vim always runs as gui mode and there is no normal mode. I don't know what it is exactly, becuase I've never used it. If you wonder, read the man page and ":help evim".

3. use_vimrc

This parameter is set by "-u" option. It can be NULL, "NONE", "NORC" and file name. The Vim skips both system vimrc and user vimrc when this option is not NULL.

"NONE" will ignore all vimrc files, while "NORC" will not ignore plugin. If it is a specific file name, the Vim will initialize only from that file.

4. n_commands, commands, cmds_tofree

They are a number of commands, commands string and flag to have to be freed. These commands executed after loading all vimrc files. "+", "-c" and "-S" options is used for them. And the number of commands cannot exceed MAX_ARG_CMDS(is defined as 10).

Only when using "-S" options, cmds_tofree flag is set. The vim allocates dynmaic size memory for commands with "-S" option, since "-S" means read commands from a file. A exe_commands function consumes the commands.

5.n_pre_commands, pre_commands

They are simular to n_commands and commands. But they are executed before loading any vimrc files by "--cmd" option. The number of commands cannot exceed MAX_ARG_CMDS like the n_commands.

A exe_pre_commands function consumes the pre_commands.

6. edit_type, tagname, use_ef

The Vim has five editing modes.

  1. FILE
  2. STDIN(with "-" option)
  3. TAG(with "-t" option)
  4. QF(with "-q" option)
  5. etc.

Editing mode have to be one of above. FILE mode edits the given file. STDIN mode reads string from stdin. TAG mode jumps to tag. QF(quickfix) mode jumps to first error, if error file exists. The tagname parameter is used only in TAG mode and have to be NULL in other modes. The use_ef parameter is used only in QF mode and have to be NULL in other modes.

7. want_full_screen

It will be always full screen in terminal, except recovery mode. The gvim can use non-full screen in the code, but gvim is not my interests.

8. stdout_isatty, term

Check whether stdout is a terminal(using isatty function in *nix system) If stdout is not a terminal, logging error messages.

9. ask_for_key

This is a flag that indicates whether to encrypt file or not. When starting vim with "-x" option, this flag is set. The encrypted files can be opened with same key.

10. no_swap_file

This is a flag that indicates whether to open with swap files. When starting vim with "-n" option, this flag is set. Since swap files are not created, it is fast, but cannot recover from crash. This option don't delete already created swap files, so it can makes conflict between opend with no_swap_file and without no_swap_file.

11. use_debug_break_level

This is debug-mode flag, starting vim with "-D" option. The initialization will break before the first vimrc command is executed.

12. window_count, window_layout

The window_count is the number of window(or tab) to open. And the window_layout is how to split winodws(or using tab). There are four vim option related with window_layout. "-p" is for using tabs to open multiple files. "-o" and "-O" is for opening many split windows("-o" is to split horizontally, "-O" is to split vertically). The last one is vimdiff and I'll explain later. You cannot open files both split windows horizontally and vertically. Options except last one will be omitted. For example, vim -o3 -O2 will open two windows vertically split .

13. serverArg, serverName_arg, serverStr, serverStrEnc, servername

These parameters are for the clientserver feature. This feature makes you can control your already open vim with command line. The vim without gui disables "--servername" by default. So if you want to use it, you have to compile source code with clientserver or use gvim. If you want to know about this feature, see ":help clientserver"

14. literal, full_path

Sorry, these are not used in *nix.

15. diff_mode

The diff_mode is flag indicates using diff mode or not. Run with "-d" option or run by the vimdiff command, trun on diff mode.


You show the parameters for initializing vim. Next time I'll show you what function determine this values and how to use it, before calling the main loop.

댓글

이 블로그의 인기 게시물

USB 2.0 케이블의 내부 구조

[C++] enum class - 안전하고 쓰기 쉬운 enum

Log Aggregator 비교 - Scribe, Flume, Fluentd, logstash

[Web] SpeechSynthesis - TTS API

[Python] cache 데코레이터로 최적화하기