MacVim: Pydiction unable to use - vim

I'm trying to add Pydiction into MacVim, I followed the readme file.
Put python_pydiction.vim in ~/.vim/after/ftplugin/ and write:
let g:pydiction_location = '~/pydiction/complete-dict'
into my .vimrc file. But when I press tab in MacVim, an error will rise:
undefined variable g:pydiction_location
Can anyone tell me where am I wrong ?

As discussed in the comments, you were editing a file that wasn't actually your .vimrc file. You may have typed:
:e vimrc
:e ~/vimrc
:e .vimrc
none of which will probably edit your actual .vimrc file. It must have a dot in front of it AND be located in your home directory. You can also type :pwd in vim to see the current working directory. If you do :e .vimrc it will create a new file in whatever directory you are in if it doesn't exist.

Do you use NERDTree? If so it seems that Pydiction and NERDTree conflict with each other in some way.

Related

Activation of `.vimrc` file

I have got a .vimrc file from one of my friends, however, vim ignores it. How can I make vim use .vimrc? Thank you for the answer.
Open vim and type ":version" and hit Enter. You will get paths to your vimrc files. Make sure that your vimrc file is not overwritten by another one (with a higher priority). Please refer to Open vimrc file.
EDIT: To see a home directory, type in vim :echo $HOME

Show the list of the files inside the folder of the current file

Imagine I'm editing file, and I want to show the list of the files inside the folder who belongs the file I'm editing, to edit one of them.
How can I do that? Is there any way using FuzzyFinder?
Did you even read FuzzyFinder's documentation (:help fuzzyfinder)? Quickly opening nearby files is one of that plugin's main features.
Without installing anything, you can do:
:Ex[plore]
to open the netrw file tree. See :help netrw.
You can also do:
:e <Tab>
Add these lines to your ~/.vimrc to make command line completion even better:
set wildmenu
set wildmode=list:full
and read :help wildmenu and :help commandline-completion.
set autochdir is a useful option to add to your ~/.vimrc, by the way.
change vim current directory to current file's:
:cd %:h
then
FuzzyFinder can do what you want (pick and edit). (:FufFile) I have mapping :
nmap <Leader>ff :FufFile<cr>
NERDTree can do that as well.
Depends on what you mean by showing the file.
To include the list of files in the currently edited files, you can do something like:
:read !ls /path/to/file
(it can be shortened to :cd %:h | read !ls if you don't mind if vim changes it's current directory...)
If you want to pick another file to edit, I'd suggest to take a look at NerdTree plugin (here is a little intro). Or you can simply issue:
:cd %:h | e .

What is the issue with vim -u /path_to/vimrc?

I share an user with other people.
Everyone has created a directory into home directory and everyone is working in his "own" directory.
I want to use my own setting when I use vim and I don't want to bother others with my preferences.
I created my .vimrc file into $HOME/my_directory
I've defined an alias my_vim="vim -u /full_path_to_home/my_directory/.vimrc"
When I edit a file with my_vim, I don't have the right colors.
I have the same problem when I use the command
:source /full_path_to_home/my_directory/.vimrc
If I copy my .vimrc file into $HOME directory, everything is fine.
Where is the problem ?
From :help vimrc
If Vim was started with "-u filename",
the file "filename" is used.
All following initializations until 4.
are skipped.
So by specifying a vimrc file, its ignoring the system-wide vimrc (/erc/vimrc/) where syntax highlighting and other things are configured. You can work around this problem by adding the following code to the top of your vimrc:
if filereadable("/etc/vimrc")
source /etc/vimrc
endif
If this sort of thing comes up a lot, I would recommend changing your $HOME to point to the current $HOME/my_directory whenever you log in.

Editting Vim Configurations

I have a very simple and easy question, but I do not know how to do it. I am on a ubuntu machine, logged in via ssh. I want to edit my vim so that I dont have to keep typing :set number or :colorscheme elflord. I would like it to remember that information. When browsing around I found out that I need to change a .vimrc file, and that is supposedly located in my home directory, however it is not, and furthermore #locate .vimrc does not locate anything. Can any help me with finding where this file is and editing the above commands?
Create ~/.vimrc with the lines you want in it:
set number
colorscheme elflord
See :help vimrc and :help vimrc-intro for more information.
Your global vimrc is located in /etc/vim you can just create a .vimrc in your home directory. This question however should be asked on http://unix.stackexchange.com or http://askubuntu.com.
You may edit it from anywhere with this command:
:e $MYVIMRC
If the file doesn't exist, just create it in ~/.vimrc

Vim :e starting directory?

I code in Vim, not an IDE.
My source code is often nested 2-3 directories deep.
~/foo$ find
xyz
bar/abc
bar/def
~/foo$ vim
// inside of vim
:e bar/abc
... some work ...
:e <-- is there a way I can have this :e start in ~/foo/bar instead of ~/foo ?
Basically, I want :e to start the directory in "pathname of last edited file"
Thanks!
There's a lot of reasons not to like autochdir as it messes up some plugins and if you end up doing :e ../../../foo.txt you are not gaining anything. Just as an idea try this cmap I knocked up
:cnoremap red edit <c-r>=expand("%:h")<cr>/
then you can type :red and get
:e /the/path/to/your/current/files/dir/
(edit: perhaps use z instead of red as there are commands that start with red)
To expand the topic, also check out the FuzzyFinder plugin and some custom mappings to rapidly jump to common files you are always editing. Eg
10 or so of your regular files should be no more than 2 keystrokes away. It helps if they are systematically named
Here's an idea I use for django.
http://code.djangoproject.com/wiki/UsingVimWithDjango#Mappings
Try the autochdir option. It will automatically change the current working directory to whatever file was most recently opened or selected. In .vimrc:
set autochdir
For more info, :help autochdir
To always change the working directory to the current file's directory I have this in my .vimrc:
if has("autocmd")
autocmd BufEnter * :lcd %:p:h
endif " has("autocmd")
Sorry, but vim's :edit command takes a path which is interpreted relative to the present working directory of the vim instance.
You do have a :cd command which you could use to :cd bar then work for a while, then :cd ...
Hope that help some.
Some time ago I asked questions related to this on the vim mailing list: http://www.mail-archive.com/vim_use#googlegroups.com/msg03266.html Maybe you will find useful tips in that thread.
I tested a lot of plugins, but since CLI based GUIs are not my taste, I simply ended up using standard vim with a few configuration settings.
As honk pointed out, this line sets the working directory to the same as the file your working on:
autocmd BufEnter * lcd %:p:h
My other tip is to use the wildmenu. It makes it easier to get an overview of the files in your current directory when you go :e and then TAB. I'm a python programmer so the last line shows how to hide auto generated files that the python interpreter spits out, but you could use it to hide java .class files or c .obj files or whatever.
set wildmode=list:longest
set wildignore=*.pyc,*pyo
:cd changes directory
:pwd prints the current one.
why not just :E? Explore directory of current file.
:help :E
This isn't exactly what you wanted, but check out NERDTree.
On vim/gVim I just have cd C:/blah/blah at the top of my vimrc. I imagine it works on all platforms.
I personally use vagrant for each project so one CD is enough, but I think you can get vim to use different config files too, -u flag I think.
Or map a key to each project you have so pressing Ctrl+F1 does cd path/to/project/1 and Ctrl+F2 does cd path/to/project/2 perhaps?
Note: I don't use any plugins

Resources