For all you contributors using VIM, what is your .vimrc file look like?

So most of my contributions to the library are happening with me working on a remote server over SSH. I’m very comfortable with VSCode which unfortunately does work very well in this kind of setup. Started using VIM but I’m confused about what the best and least complicated way is to get the following features I’m use to in VSCode …

  • Autocompletion/Intellisense (especially one that works against a custom Anaconda environment)
  • Line numbers to show up on left-side of editor
  • Color coding
  • Being able to navigate to the definition of variables/classes/methods by clicking on them (for example, if I see a class inheriting from Callback, I’d like to be able to click on Callback in that file and have it take me to the file where Callback class is defined.

I’ve seen some crazy complex .vimrc files and I’d rather avoid that as much as possible. Any recommendations, thoughts, advice, etc… is very appreciated.

5 Likes

I keep mine pretty simple:

https://github.com/fastai/dotfiles/blob/master/.vimrc

BTW that repo is a handy way to keep your config synced across machines:

https://github.com/fastai/dotfiles

6 Likes

I believe the fastai dotfiles repo is private. Would love to see your config though!

1 Like

Yah I get a 404 error myself so it looks like its private. +1 on liking to see what it looks like.

Thanks

Apologies - fixed now.

2 Likes

FYI: This is what I did to get everything operational on my end:

  1. Install powerline
pip install powerline-status
  1. Install Vundle
mkdir ~/.vim/bundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  1. Change the .vimrc as follows since it wasn’t finding powerline:
python import sys; sys.path.append("/home/<username>/.local/lib/python3.6/site-packages")
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
1 Like

Thanks!!

The first two worked wonderfully. The third one, I’m struggling a bit with system default python 2 and conda. I’ll dig into it further later today.

Yah Google a bit on that one, I remember seeing some other options with configuring powerline for similar setups, but I can’t recall off hand what they were.

So, I was getting this error:

Error detected while processing /home/hiromi/.vimrc:
line   10:
E319: Sorry, the command is not available in this version: python import sys; sys.path.append("/home/hiromi/src/miniconda3/envs/fastai/lib/python3.6/site-packages")
line   11:
E319: Sorry, the command is not available in this version: python from powerline.vim import setup as powerline_setup
line   12:
E319: Sorry, the command is not available in this version: python powerline_setup()
line   13:
E319: Sorry, the command is not available in this version: python del powerline_setup
Press ENTER or type command to continue

I ended up running:

vim --version | grep +python

Which returned +python3, so I ended up changing python to python3 and everything works now :slight_smile:

4 Likes

vim --version | grep +python

And for those unfortunate souls for whom above command returns blank, you can do the following to compile vim with python support (source):

**Install**

sudo apt install libncurses5-dev \
libgtk2.0-dev libatk1.0-dev \
libcairo2-dev python-dev \
python3-dev git

**Remove Vim if you already have**
sudo apt remove vim vim-runtime gvim  

**configure and make**
cd /usr && sudo git clone https://github.com/vim/vim.git && cd vim  

sudo ./configure --with-features=huge \
--enable-multibyte \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ \
--enable-python3interp=yes \
--with-python3-config-dir=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/ \
--enable-gui=gtk2 \
--enable-cscope \ 
--prefix=/usr/local/

sudo make VIMRUNTIMEDIR=/usr/local/share/vim/vim81 && sudo make install

After that I had to modify my .vimrc as below (combining @wgpubs @hiromi 's solutions earlier) :

python3 import sys; sys.path.append("/home/<username>/anaconda3/envs/fastai-v1/lib/python3.7/site-packages")
python3 from powerline.vim import setup as powerline_setup
python3 powerline_setup()
python3 del powerline_setup
2 Likes

I was able to avoid recompiling vim from source by installing the vim-nox version which comes with python3 support compiled in.

After install just updated the alternatives and modified vimrc as above (also changing the sys.path to point to where my python site-packages were stored).

1 Like

FYI: As I’m relying more on Anaconda for my default python, in my most recent build I had to change

python import sys; sys.path.append("/home/<username>/.local/lib/python3.6/site-packages")

to …

python import sys; sys.path.append("/home/<username>/anaconda3/lib/python3.6/site-packages")

Hi everyone,

With Jeremy’s .vimrc, I had the lines 9-11 powerline error while
vim --version | grep +python
was returning +python3

On my side what worked was running
pip3 install --user powerline-status
as described on https://unix.stackexchange.com/questions/306127/powerline-in-vim-errors-setting-up
:slightly_smiling_face:

Could able to fix it?. if yes, kindly share what did you do

thanks

http://vim.fisadev.com
This project seems to offer a python setup for VIM which goes pretty close to an IDE.
This can be helpful while working in a remote machine.

1 Like