Added new scripts for vim functionality that is not working - vim

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.

Related

Not an editor command: :Ex

I would like to always open a vertical split with Explore whenever I open a file in vim. So I added the following list to my init.vim
topleft vsplit | :vertical resize 30 | :Ex
however I get the following error message.
Not an editor command: :Ex
however I get the following error message.
So the command is invalid. :Ex is provided by a plugin (usually netrw). The message means that netrw is not loaded (yet).
I added the following list to my init.vim
Please, take your time reading :h startup. To put it short, vimrc (or init.vim) is processed long before any plugin is loaded. You really should delay your command until VimEnter event. Kind of
if v:vim_did_enter
DoSomethingIfSourcedManually
else
autocmd VimEnter * ++once ++nested DoSomethingOnStartup
endif

.vimrc "set pastetoggle=<F2>" giving error while running "source .vimrc"

I'm using CentOS 7 and added set pastetoggle=<F2> in .vimrc to toggle the auto-indentation.
While running source .vimrc, it is throwing the below error
-bash: .vimrc: line 4: syntax error near unexpected token `newline'
-bash: .vimrc: line 4: `set pastetoggle=<F2>'
Here's my .vimrc file for reference
set ai
set tabstop=2
set expandtab
set pastetoggle=<F2>
Please help me and let me know, how to resolve the issue?
You are trying to source a vim config file in your shell, which would indeed throw an error. If you are trying to update the vim config on the go, then after updating your ~/.vimrc file(assuming you are using vim to edit the vimrc file) , from vim open the command line mode by pressing : and type in source % (where % denotes current file). Then your new config gets updated on the go.
If you're lazy like me then bind it to a key for sourcing, like so in normal mode :
nnoremap <leader>so :w<cr>:source %<cr>
If you are using some other text editor to edit ~/.vimrc, then save and exit the file, then open a new instance of vim and your changes get updated automatically.

syntax error near unexpected token `newline' for my nnoremap in .vimrc?

Here is the configuration of my .vimrc.
For the 12 th line.
nnoremap <F12> :!/opt/google/chrome/chrome '%:p'<CR>
source .vimrc
bash: /home/debian9/.vimrc: line 12: syntax error near unexpected token `newline'
bash: /home/debian9/.vimrc: line 12: `nnoremap <F12> :!/opt/google/chrome/chrome '%:p'<CR>'
How to fix it ?
Don't use source in your Bash shell; the right command is :source .vimrc inside Vim!
Please note that reloading your Vim configuration may work, or not (depending what you do, how you define :autocmds, whether the changed configuration affects already loaded plugins). If in doubt, it's easier to just :quit Vim and restart it; the new .vimrc will then be loaded automatically.
The syntax of your Vim configuration in ~/.vimrc is Vimscript; this is only understood by Vim itself. Your shell configuration would be put in (for example) ~/.bashrc; you can source that in your shell.

Unknown function: NERDTreeAddKeyMap

I'm trying to add a keymap to my NERDTree configuration which executes the current FileNode and displays the output. I put this script file in my ~/.vim/plugin directory.
The keymap actually works when I source the script file from within Vim, but displays the error "Unknown function: NERDTreeAddKeyMap" when starting Vim.
I used Pathogen for my plugins, and in my ~/.vimrc I have all the necessary :
" Enable filetype plugins
filetype plugin indent on
" Start Pathogen plugin to load bundle
call pathogen#infect()
call pathogen#helptags()
As well as NERDTree in my ~/.vim/bundle directory.
Where should I move the script so that it is automatically loaded on Vim startup, without this ugly error ?
The filetype plugin indent on line is supposed to come after the two Pathogen lines.
The relevant documentation says:
This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
So, since you use Pathogen, the right place is probably:
~/.vim/bundle/[nerdtree directory]/nerdtree_plugin/mymapping.vim

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

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.

Resources