Having an issue with <Leader> key and plugin (particularly EasyMotion) - vim

So I am really new to VIM but was attempting to add some plugin's one of which is EasyMotion.
According to the vid tutorials at NetPlus, and Vim's Wiki Plugin Page, after dropping the plugin's .vim file in the plugins direction (on Windows) I should be able to initiate the EasyMotion plugin by hitting (from within a loaded file):
<Leader><Leader>w"
And according to the VIM documentation, Leader is set to the mapleader variable which is by default "\" unless change. I haven't changed it but hitting "\" does nothing but beep (windows error bell).
I did try even mapping:
let mapleader = ","
let g:mapleader = ","
and nothing changed.
UPDATE
I came across these errros when I accidently tried loading my _vimrc file by Vim (right clicked on file and chose to open with Vim) -> I think this might give some insight, but I haven't a clue why:
ERROR
Error detected while processing d:\Program Files (x86)\Vim\vimfiles\plugin\
EasyMotion.vim:
line 24:
E117: Unknown function: EasyMotion#InitOptions
line 39:
E121: Undefined variable: g:EasyMotion_hl_group_target
E116: Invalid arguments for function EasyMotion#InitHL
line 40:
E121: Undefined variable: g:EasyMotion_hl_group_shade
E116: Invalid arguments for function EasyMotion#InitHL
line 69:
E117: Unknown function: EasyMotion#InitMappings

I don't use the aforementioned plugin, so cannot help with it specifically, but as far as the other part goes, you can see what your leader is mapped by
:echo g:mapleader
Vim plugins are usually (if you're not using some plugin to manage plugins, like Pathogen or Vim-Addon-Manager) saved either in $VIM\plugins (bad), or in $VIMFILES\plugins (good), on Windows. If you're on unix, just replace \ with /.
You can also find out where your $VIM, $VIMFILES ... directories are by echoing them ... :echo $VIMFILES.
One more thing about mapleader. It is not dynamic - that is, once the mapping is defined with
<leader>some_key
and you change the leader variable, it does not redefine the mapping. So your leader has to change (for example, in your vimrc) before the actual mapping that is using it happens.

The answer came out to be that I had not added the autoload .vim file to the autoload directory. This was why I was getting the specific errors.

Related

Added new scripts for vim functionality that is not working

I am in a Mac OS and I just added some scripts to get new functionality from my vim editor and when I go back into the vimrc file I continue to get this error:
vim ~/.vimrc
Error detected while processing /Users/danale/.vimrc:
line 12:
E117: Unknown function: pathogen#infect
E15: Invalid expression: pathogen#infect()
I have looked at similar posts here that are not very helpful. Ultimately, I would like to use nerdtree configuration so I can use VIM as my IDE.
If I hit enter anyway, I get this error:
Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree | endif
and it does not take me to a nerdtree type of view just an empty welcome to vim view.
You need to install pathogen.

Getting vim shebang plugin working

Sorry if this is a silly question, I'm brand new to Vim.
I've downloaded the following shebang plug-in (http://www.vim.org/scripts/script.php?script_id=3366 version 1.1) to the directory .vim/plugin
When I open a file (e.g. "vim pypr.py") and in type in ":\X [enter]" (in normal mode) I encounter the following error:
"E10: \ should be follow by /, ? or &"
My .vimrc file in its entirety is as follows:
execute pathogen#infect()
syntax on
filetype plugin indent on
syntax enable
set background=dark
colorscheme solarized
map <leader>X :w<CR>:call SetExecutable()<CR>
I googled the error, and the results were not helpful in resolving the problem.
Any ideas what I'm doing wrong? I suspect I just don't know how to use the leader command.
The mapping
map <leader>X :w<CR>:call SetExecutable()<CR>
says to enter \X where \ is leader's default value. You can find the current leader value by
:let mapleader
It is \ if it says Undefined variable or it will show the current leader value.
Or you can map to another key like F6 so that pressing F6 will achieve what you are looking
nnoremap <F6> :w<CR>:call SetExecutable()<CR>
With mapping you don't need : and [Enter] — just type \X.

Error after 'source ~/.vimrc' after setting up pathogen

I get this error when I source my .vimrc file,
> source ~/.vimrc
bash: /home/dev/.vimrc: line 1: syntax error near unexpected token `('
bash: /home/dev/.vimrc: line 1: `call pathogen#infect()'
The contents of my .vimrc file are,
call pathogen#infect()
syntax on
filetype plugin indent on
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set backupdir=~/.vimbackup
set directory=~/.vimdir
I've also tried using 'execute pathogen#infect()' in the chance that it doesn't like the 'call' keyword.. and I've tried passing in the path to my bundle file as follows,
call pathogen#infect('~/.vim/bundle/{}')
I've also tried just putting 'bundle/{}' as the argument to infect... But I don't understand vim/bash well enough to know what direction to go in, would appreciate any help...
The reason I'm trying to source my .vimrc file is because everytime I use vim to edit a file I get litter from the file in the form of files being left that have this format,
.file_i_just_worked_on.un~
which is really annoying making my dir messy. I've read that I need to have
set backupdir=~/.vimbackup
set directory=~/.vimdir
to not have those files being dropped by vim everywhere... Would appreciate any help with this issue.
You're asking bash to read your .vimrc file, but it isn't equipped to parse that.
You instead need to have vim read it. You can either start a new instance of vim, or type :source ~/.vimrc from normal mode within a running vim session.
If vim is still creating backup files in your current directory, that may be because you haven't created the ~/.vimbackup or ~/.vimdir directory.
As qqx mentioned, I need to ":source ~/.vimrc" inside of vim, not use bash...
To get rid of the .file.un~ files I need to have a
set undodir=path/to/dir
in my vimrc

Error open files after creating ~/.vimrc

Before today I was using /etc/vim/vimrc to configure my vim setup. Today I thought of creating .vimrc file. So, I used
touch .vimrc
cat /etc/vim/vimrc > .vimrc
So, now when I open any file with vim I get the following errors:
Error detected while processing /home/ronnie/.vimrc:
line 68:
E122: Function SplitColors already exists, add ! to replace it
line 77:
E122: Function ChangeColors already exists, add ! to replace it
line 171:
E174: Command already exists: add ! to replace it
line 174:
E174: Command already exists: add ! to replace it
Press ENTER or type command to continue
I have both /etc/vim/vimrc and .vimrc file located in my system. So, is this the reason I am getting this error because from now on I would like to use only .vimrc to configure my vim setup.
You're defining functions that have the same name as some already defined. Adding an exclamation mark after function "overwrites" the previous definition, and in your case will stop the error message from showing.
This is the solution by example since most of the answers are correct above but they don't directly help you solve the problem. Areas of interest in bold.
" code with redefinition issues
function CloseDuplicateTabs() endfunction
command CloseDupTabs :call CloseDuplicateTabs()
" fixed code with overrides
function! CloseDuplicateTabs() endfunction
command! CloseDupTabs :call CloseDuplicateTabs()
Why not add ! to your function definitions as suggested? it will make vim stop complaining.
Alternatively you could remove those definition from /etc/vim/vimrc
The problem is that both /etc/vim/vimrc and .vimrc are sourced. This depends on several factors; see the details at :help .vimrc.
In general, the system-wide Vim config should reside in the former file, and your personal customizations in the latter. For single-user systems, there isn't much of a difference, but you did the right thing in moving the stuff into your home directory. Just delete the duplicate functions etc. from the former file, or remove it completely if you've moved everything to your .vimrc.

MacVim: slimv does not start

I'm using MacVim (kind of gvim for OSX) and try to get the slimv plugin running.
Sadly it's not working out of the box. In fact, it does not start up at all.
My setup:
MacVim (32bit cause of this) (vim 7.3)
:scriptnames does not list ftplugin/slimv.vim while plugin/paredit.vim is listed
:set ft? shows filetype=lisp for .lisp files
:messages shows no errors
:filetype filetype detection:ON plugin:ON indent:ON
:echo g:paredit_loaded 1
:echo g:slimv_loaded E121: Undefined variable: g:slimv_loaded \ E15: Invalid expression: g:slimv_loaded
compiled with +python (2.7)
SBCL and slime are installed - works flawless with emacs.
I tried it with and without let g:slimv_swank_cmd = ... in .vimrc and changed the line recommended on the plugin page from
let g:slimv_swank_cmd = '!osascript -e "tell application \"Terminal\" to do script \"sbcl --load ~/.vim/slime/start-swank.lisp\""'
to
let g:slimv_swank_cmd = '!sh -c "sbcl --load /Applications/MacVim.app/Contents/Resources/vim/runtime/slime/start-swank.lisp" &'
since the osascript was not working and I don't know how to fix it. But a similar call to xterm is sufficient for Linux so my sh call should be fine.
Well, I got no idea what to try next. :/
The problem got solved by installing slimv to ~/.vim instead of the vim ebedded in MacVim. Maybe some kind of bug? However, Common Lisp + vim - I just love it.
Because moving the slimv plugin to ~/.vim fixed it, I suspect the problem is that MacVim's default /Applications/MacVim.app/Contents/Resources/vim/runtime/ftplugin/lisp.vim is being sourced before the ftplugin/lisp/slimv-lisp.vim file provided with slimv.
Both of those files (lisp.vim and slimv-lisp.vim) start with code like this:
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
and so whichever file gets sourced first will prevent the other file from running since vim does finish (exits the script) if it detects that another *lisp*.vim script was run previously and therefore set the b:did_ftplugin buffer-local variable.
You can tell this is happening by running MacVim from the command line with the arguments:
-V20macvim-log.txt hello.lisp
Then quit the MacVim session that starts up, and look at the macvim-log.txt file it created.
Search for b:did_ftplugin and you'll see it referenced each time lisp.vim or slimv-lisp.vim runs, and you can see that lisp.vim runs first, which prevents slimv-lisp.vim from working.
Moving your slimv install from the /Applications/MacVim.app/ dir to your ~/.vim dir will change the order so that slimv-lisp.vim is sourced before lisp.vim, and then slimv will work.
If slimv.vim is not listed in :scriptnames and g:slimv_loaded is undefined then you don't have the plugin loaded at all. I guess you don't have filetype plugins enabled. Paredit is a general plugin but slimv.vim is a filetype plugin and filetype/indent plugins must explicitly be enabled. Try to add these lines to your .vimrc:
filetype plugin on
filetype indent on
The problem got solved by installing slimv to ~/.vim instead of the vim ebedded in MacVim. Maybe some kind of bug?
However, Common Lisp + vim - I just love it.

Resources