简体   繁体   中英

How to detect vim vs gvim in .vimrc

I am trying to write a new .vimrc for my ubuntu laptop. I use Intellij IDEA with the Ideavim plugin along with vim and gvim. I want to create one .vimrc common for vim, gvim and VIM mode in Intellij Idea.

In, Idea, :set relativenumber command is not working and I want to enable it just for vim and gvim.

Is there a way in which I can detect if it is vim or gvim and then run :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! It can read vim's config file and load some option settings, which are "supported" by ideavim. I believe that background there is a mapping between vim's options and the options/functions of intellij editor implemented by java. Ideavim cannot interpret or execute vimscript either. You can try some vim functions, they won't work with ideavim. For example, the has() function mentioned by Ronakg.

On the other side, vim doesn't know what's ideavim, it cannot get information of Intellij process either.

I use both vim and ideavim. I won't adjust my vimrc for ideavim. I don't expect my ideavim to become a fully-armed vim editor (I love to have it though). 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. My experience tells that ideavim only applies vim options it supports. For more detail, pls read the help/doc of ideavim.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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