How to unload all the plugins from vim and change VIMRUNTIME? - ssh

I have an account at my hosting providers server and I can't install my own copy of vim.
So the only personalization I can make is editing .vimrc in my account, but it won't suffice
What I'd Like to do is:
on startup I'd like to unload all the plugins and loaded stuff, and tell vim to use other folder as its' runtime.
Any idea how to aproach it?

You can start your vim with -u NONE. From the man-page:
-u {vimrc} Use the commands in the file {vimrc} for initializations.
All the other initializations are skipped. Use this to
edit a special kind of files. It can also be used to skip
all initializations by giving the name "NONE". See ":help
initialization" within vim for more details.
For changing $VIMRUNTIME at runtime, use
:let $VIMRUNTIME = "/new/path/"

To answer your question: you just need to set the runtimepath option in your .vimrc file, because your .vimrc is read before any plugins are loaded.
However, the default runtimepath value usually includes the ~/.vim folder (use :set runtimepath? to check), so you should be able to add whatever plugins you need to the ~/.vim folder. Also you can prevent many plugins from loading by adding a line such as :let g:loaded_<plugin name> = 1 to your .vimrc file. Check the help docs for each plugin to find out how to do this.

Related

How to temporarily change a setting in VSCode

When I am editing a standalone Python file in VSCode (not part of a workspace) I will often need to alter the value of python.pythonPath to reflect a specific virtualenv I am using to run that code.
As the setting is just for the one file, I don't want to change my persistent global settings, and I don't have workspace settings. Is there a way to change a setting just for this session? (Ideally, just for this one file, but I don't expect that to be possible, so I'd be happy with "just for the session"). If there isn't a built in way to do this, is there an extension which allows this? Or even an extension API that I could use to write my own extension for this?
As an alternative, is there a way to use an environment variable in a setting, and then set that environment variable for the current VSCode process? That would have the same effect, it would just require me to set up my user settings specifically to allow this usage.
If you launch vscode from the terminal after having activated your virtualenv, vscode will automatically use the aforementioned virtualenv (with no modification to your settings):
Exemple:
source venv/bin/activate
code .
Note: if vscode is already opened, use code -n . in order to open the file/folder in a new window.

ssh vs file associations / mime types

So, on my local machine I tweaked my
/usr/(local/)share/mime/packages/freedesktop.org.xml,
to make a few additional file extensions be detected as PHP.
<glob pattern="*.inc"/>
<glob pattern="*.module"/>
<glob pattern="*.install"/>
(this is for Drupal files)
nautilus uses this information to open the file in gedit.
gedit uses this information to enable the correct PHP syntax colors.
Now, I want the same for files opened via ssh.
I know this used to work in the past, but I don't remember what exactly I changed.
Whatever I did back then, it was probably wiped with the 11.10 Oneiric Ocelot upgrade.
What I want,
open an ssh folder in nautilus
double-click a file named "something.module"
have it open in gedit, with the correct PHP syntax colors enabled.
There are different things you might want to check.
1) Edit /usr/(local/)share/mime/packages/freedesktop.org.xml
Search for "php", and the section with <glob>. Add your own extensions there, as explained in the question above.
2) Run sudo update-mime-database /usr/share/mime
You might have to do this after you changed the settings as in (1).
3) Edit /usr/share/gtksourceview-3.0/language-specs/php.lang (path may vary)
Look for <property name="globs">, and add your custom extensions.
(see http://live.gnome.org/Gedit/FAQ#How_to_set_the_default_highlight_mode_for_new_files.3F)
4) Restart gedit.
Probably enough to just close and re-open the tab where you wanted to edit, but if that doesn't help, close and re-open all gedit windows.

Start two instances of IntelliJ IDE

Well my question is pretty simple, how do I start two instances of IntelliJ (community edition).
When I have one instance started and I try to start another one, all that happens is that my started instance gets focus.
I'm developing Android applications using IntelliJ.
Any thoughts?
Press Ctrl+Alt+SChoose Appearance & Behavior, then System Settings, check radio button: Open project in new window.
You need to configure each instance to use its own folders for config/plugins/system locations by editing idea.properties file on Windows/Linux and Info.plist on Mac. You can find the details in FAQ.
Note that normally it's not necessary since you can open multiple projects in different IDEA frames within the same instance using File | Open or Open Recent.
CrazyCoder has roughly the right idea. However, setting the config file alone was not sufficient for me to run multiple instances. Here are my steps to get this going (in GNU/Linux, I am sure you can figure out equivalent in other systems):
Create a folder/directory per instance you want to run.
mkdir -p ~/idea/instance-0
Go to the installation directory (e.g. /opt/intellij) and copy the idea.properties (in bin) file over to your instance directory.
cp /opt/intellij/bin/idea.properties ~/idea/instance-0/
Copy 3 more directories: system, plugins, and config. I highly recommend doing this without the running instance
cp -r /opt/intellij/system ~/idea/instance-0/
cp -r /opt/intellij/plugins ~/idea/instance-0/
cp -r /opt/intellij/config ~/idea/instance-0/
mkdir ~/idea/instance-0/log
Open your idea.properties file and update the configurations for your directories:
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE config folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.config.path=${user.home}/config
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE system folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.system.path=${user.home}/system
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.plugins.path=${user.home}/plugins
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.log.path=${user.home}/log
Now, you can start IntelliJ with the new setup:
IDEA_PROPERTIES=~/idea/instance-0/idea.properties /opt/intellij/bin/idea
Obviously, you probably want to put the command in a script file for invocation. This seems to work for me.
File->Settings->General and in section "Startup/Shutdown" check "Confirm window to open project in"
With Ultimate 2020.2, go to Appearance & Behavior > System Settings in the settings dialog and select the "Ask" option for "Open project in"
As per the directions from jetbrains you'll need go to the 'General' page of the 'Settings' dialog and chose 'Open project in a new window'. Then proceed to open a project as you normally do. IntelliJ should then startup a completely new instance.
There is an other very quick way of doing it. There is always an EAP version of the IDE and it can run at same time with the current one. For example I am using AppCode 2017.2 and 2017.3 EAP in parallel.
Go go to IntelliJ | Tools | Create Command-line Launcher...
Keep the defaults (which creates a binary named "idea"):
Now, go to your command line.
Cd to your project directory and type: idea .
This will create a .idea directory for IntelliJ configurations for that project, which it will re-use each time to start IntelliJ from that directory.
You can now go to a different project directory and type: idea .
Assuming you left the previous IntellJ IDE open, you will now have two IntellJ IDEs open, one for each project.
Notes:
1) If your project uses environment variables, then I'd recommending opening a separate terminal tab/window for each project and set that project's environment variables before running: idea .
2) Depending on what you're trying to accomplish, you may need to modify your classpath (or settings like Project GOPATH) for each IntelliJ instance.
My answer is not directly related to the question but its a solution for some cases where we think we need 2 Intellij instances.
For my issue I was thinking to launch 2 Intellij instances. But after careful thinking and searching for other options, I found an easy and quick solution and I wanna share with the community
If you are looking to compare files between different branches, and you wanna compare the difference, that can be done with git comparison. You don't need 2 different Intellij instances.
My Case:
In my case, I wanted to copy very specific code from 1 branch to another and I wanted to compare the difference between the code. The restriction was, I can't do git merge or cherry-pick because we didn't want full commit to be part of new branch. Just few necessary lines were required in the new branch.
My Solution:
Select the branch
Open the file where you wanna insert code
Right Click -> Git -> Compare with... (refer to pic)
Select the branch and you will get the difference
Append or Copy the difference
If you have new files or directories, you can create it manually and copy-paste the content
I know this answer doesn't directly relates to what has been asked, but sometimes we miss alternative solutions.
Hope this can be helpful as an alternative solution.
In addition to the above comments from #crazycoder and #magice, Make sure that you are not trying to load Pycharm with the same project two times which happened to me!!!.
For example, in windows10 already loaded with ONLY one project in PyCharm and tried to load another Pycharm instance by clicking on the PyCharm desktop shortcut or from task-bar if added. In this case, Pycharm will not load the second instance.
I have wasted some time here. So, wanted to share with the community as it will help someone out there!!
Cheers,

Setting environment variables in Rails

I'm trying to make my project OSS, and I'd like to remove any sensitive info from the configs. I'm trying to have ENV['DB_PASS'] = mypassword. Where would I set this? I've tried export DB_PASS=mypassword in my .bashrc file. But that's not working.
Are you sure export isn't working? Have you tried echo $DB_PASS? (Also, changes to .bashrc won't take effect until the next time you log in.)
A more common way to handle this problem is to create a separate config file that is not tracked in your repository, and then provide a config.sample file demonstrating the common configuration options but with dummy values.

.vimrc for IntelliJ Idea's vim plugin

I am using the vim plugin for IntelliJ Idea.
Where should I place the .vimrc for that plugin.
Using Windows XP
The latest version of the plugin will read settings from a file named .ideavimrc in the home directory.
On *nix, the home directory can be accessed at ~.
On Windows, you can use the %HOMEPATH% environment variable. (Normally, "C:\Users\<User Name>" or "C:\Documents and Settings\<User Name>", depending on your Windows version.)
If you rename your .vimrc to _ideavimrc in your ~ directory (/Users/ in windows)
Underscore is used instead of the . in windows for vim apparently
IntelliJ will honour it
Was tearing my hair out for a while getting this to work.
On my mac i simply ran ln -s "$HOME/.vimrc" "$HOME/.ideavimrc" to create a symlink so IntelliJ would use the same .vimrc as my standard vim.
My .vimrc is very simple. However, if there is config that is incompatible between IntelliJ and vim then you might have issues with this approach.
echo %homepath%
gives me my "home directory" on Windows XP,
where I need to put my .vimrc.
Unfortunately, the vim plugin for JetBrains doesn't effectively support the full functionality of a .vimrc. The file that the plugin uses is called .ideavimrc. This is what you should use and it should be placed in your home directory (see this other answer for details, particularly for Windows).
I have a very comprehensive .vimrc that I use. Unfortunately, I had to pare that down quite a bit to work as .ideavimrc. You can look at the gists to see the differences. For what it's worth, it's still provides nice functionality, including buffer switching across tabs and splits.
.ideavimrc
.vimrc
So why not just use the same file (i.e., .vimrc) for both? Well, for one thing, you need some settings in .ideavimrc that give precedence to the vim plugin for certain keyboard shortcuts that conflict with the IDE. See the top of my .ideavimrc for my settings (for example, sethandler <C-B> a:vim). The other thing is that it seemed that when my more complicated .vimrc couldn't be processed, other settings (such as just set noerrorbells) also wouldn't take effect.