简体   繁体   English

如何在.vimrc中检测vim vs gvim

[英]How to detect vim vs gvim in .vimrc

I am trying to write a new .vimrc for my ubuntu laptop. 我正在尝试为我的ubuntu笔记本电脑编写一个新的.vimrc。 I use Intellij IDEA with the Ideavim plugin along with vim and gvim. 我将Intellij IDEA与Ideavim插件以及vim和gvim一起使用。 I want to create one .vimrc common for vim, gvim and VIM mode in Intellij Idea. 我想在Intellij Idea中为vim,gvim和VIM模式创建一个通用的.vimrc。

In, Idea, :set relativenumber command is not working and I want to enable it just for vim and gvim. 在Idea中, :set relativenumber命令不起作用,我只想为vim和gvim启用它。

Is there a way in which I can detect if it is vim or gvim and then run :set relativenumber ? 有没有一种方法可以检测到它是vim还是gvim,然后运行:set relativenumber Or, is there a way I can create a separate common script that will be run in all 3 of them and an individual script file for each of them separately? 或者,是否有一种方法可以创建一个单独的通用脚本(将在所有这三个脚本中运行),并为每个脚本文件分别创建一个脚本文件?

您可以使用if has("gui_running")来检测您是在vim还是gvim运行。

First of all, ideavim is not vim! 首先,ideavim不是vim! It can read vim's config file and load some option settings, which are "supported" by ideavim. 它可以读取vim的配置文件并加载一些选项设置,这些设置受ideavim支持。 I believe that background there is a mapping between vim's options and the options/functions of intellij editor implemented by java. 我相信背景是vim的选项和java实现的intellij编辑器的选项/功能之间存在映射。 Ideavim cannot interpret or execute vimscript either. Ideavim不能解释或执行Vimscript。 You can try some vim functions, they won't work with ideavim. 您可以尝试一些vim函数,但它们不适用于ideavim。 For example, the has() function mentioned by Ronakg. 例如,Ronakg提到的has()函数。

On the other side, vim doesn't know what's ideavim, it cannot get information of Intellij process either. 另一方面,vim不知道ideavim是什么,它也无法获取Intellij进程的信息。

I use both vim and ideavim. 我同时使用vim和ideavim。 I won't adjust my vimrc for ideavim. 我不会为ideavim调整我的vimrc。 I don't expect my ideavim to become a fully-armed vim editor (I love to have it though). 我不认为我的ideavim会成为全副武装的vim编辑器(尽管我很喜欢拥有它)。 It is enough for me, that I can apply some fundamental vim operations when I program java in intellij, Eg navigation, textobject etc. If there are some options, functions in your vimrc, which are not supported by ideavim, you don't have to care about them. 对我来说足够了,当我在intellij,Eg导航,textobject等中编程Java时,我可以应用一些基本的vim操作。如果您的vimrc中有一些想法,功能不被ideavim支持,则您没有关心他们。 My experience tells that ideavim only applies vim options it supports. 我的经验告诉我,ideavim仅应用它支持的vim选项。 For more detail, pls read the help/doc of ideavim. 有关更多详细信息,请阅读ideavim的帮助/文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM