Skip to content

Commit

Permalink
dosinst: Support setting Vi compatibility from command line
Browse files Browse the repository at this point in the history
Also add nocp setting.
  • Loading branch information
k-takata committed Oct 12, 2018
1 parent f0de369 commit 5f0390c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/dosinst.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ int choice_count = 0; /* number of choices available */
enum
{
compat_vi = 1,
compat_vim,
compat_some_enhancements,
compat_all_enhancements
};
char *(compat_choices[]) =
{
"\nChoose the default way to run Vim:",
"Vi compatible",
"Vim default",
"with some Vim enhancements",
"with syntax highlighting and other features switched on",
};
Expand Down Expand Up @@ -1161,6 +1163,11 @@ install_vimrc(int idx)
case compat_vi:
fprintf(fd, "set compatible\n");
break;
case compat_vim:
fprintf(fd, "if &compatible\n");
fprintf(fd, " set nocompatible\n");
fprintf(fd, "endif\n");
break;
case compat_some_enhancements:
fprintf(fd, "source $VIMRUNTIME/defaults.vim\n");
break;
Expand Down Expand Up @@ -2239,6 +2246,8 @@ print_cmd_line_help(void)
printf(" Remap keys when creating a default _vimrc file.\n");
printf("-vimrc-behave [unix|mswin|default]\n");
printf(" Set mouse behavior when creating a default _vimrc file.\n");
printf("-vimrc-compat [vi|vim|defaults|all]\n");
printf(" Set Vi compatibility when creating a default _vimrc file.\n");
printf("-install-popup\n");
printf(" Install the Edit-with-Vim context menu entry\n");
printf("-install-openwith\n");
Expand Down Expand Up @@ -2316,6 +2325,20 @@ command_line_setup_choices(int argc, char **argv)
else if (strcmp(argv[i], "default") == 0)
mouse_choice = mouse_default;
}
else if (strcmp(argv[i], "-vimrc-compat") == 0)
{
if (i + 1 == argc)
break;
i++;
if (strcmp(argv[i], "vi") == 0)
compat_choice = compat_vi;
else if (strcmp(argv[i], "vim") == 0)
compat_choice = compat_vim;
else if (strcmp(argv[i], "defaults") == 0)
compat_choice = compat_some_enhancements;
else if (strcmp(argv[i], "all") == 0)
compat_choice = compat_all_enhancements;
}
else if (strcmp(argv[i], "-install-popup") == 0)
{
init_popup_choice();
Expand Down

0 comments on commit 5f0390c

Please sign in to comment.