In my vimrc,
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
but when I start writting a file, it tips error:
Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree
Anyone can help me ?
I tried to install NERDTree using vim-plug, so when I started vim and run :PlugInstall, I can use :NERDTree command but after going out it was no available, reason is I didn't download plugin cause I used github, so according to documentation you have to use it on demand and wrap it up your instruction:
call plug#begin('~/.vim/plugged') " Specify folder
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
call plug#end() " Initializes plugins
So your plugins are available now, and you can use your instructions:
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
Related
I am on windows 10. I set up my files like this.
~/.vimrc
set nocp
source ~/vimfiles/autoload/pathogen.vim "location of my pathogen.vim
call pathogen#infect()
call pathogen#helptags()
autocmd vimenter * NERDTree
syntax on
filetype plugin indent on
~/vimfiles/autoload/pathogen.vim
~/vimfiles/bundle/nerdtree
When I open via the desktop application Vim I can use the :NerdTree command okay, I can also use other pluings, but when I open the vim editor from git bash or cmd.
One thing to note is that I do not need the autocmd vimenter command to run :NERDTree in Vim application, but it errors when I try to open :NerdTree from the vim editor.
Any ideas for what I can check?
On Windows, Vim expects your vimrc to be in either of these two locations:
%UserProfile%\_vimrc (note that it's a _, not a .),
%UserProfile%\vimfiles\vimrc (note that there's no _ or . anymore).
The latter is generally recommended because it allows you to keep all your Vim stuff under a single, easy to move around, directory.
Once you have moved your vimrc to a correct location you can remove the first line which is completely useless as Vim sets the nocompatible option itself when it finds a vimrc at an expected location.
See :help vimrc and :help 'nocompatible'.
The second line is also useless because lines 3 and 4 use a feature called "autoloading" through which Vim already knows where to find those functions.
See :help autoload.
My setup is:
Windows7 SP1 (Enterprise)
gVim 7.3
Whenever I open a file, Gvim will create 2 folders in the same folder as the file is located. The folders' names are Files and (x86). This only started happening recently. Any idea what could be causing this?
My _vimrc files is as follows
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
behave xterm
set ic
set nu
set ai
set noswapfile
set nobackup
source $VIMRUNTIME/colors/darkblue.vim
set expandtab " expand tabs
set shiftwidth=3
set softtabstop=3
set ruler " show the cursor position all the time
source $VIMRUNTIME/plugin/linuxsty.vim
Do you have any plugins installed? Then try running without them (--noplugin argument), also try a plain Vim gvim -N -u NONE.
It looks like some plugin doesn't do proper quoting of an argument.
You can capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine the vimlog log file for suspect commands.
I have written
autocmd! FileType tex set nonumber
in my _vimrc (running Windows), but when I open up my test.tex I still see line numbers.
If, after opening the file, I type set filetype=tex then the line numbers disappear.
How can I get it to evaluate when I open the file?
Try
autocmd! FileType plaintex set nonumber
(I'm new to Linux and Vim, and I'm trying to learn Vim but I'm having some issues with it that I can't seen do fix)
I'm in a Linux installation (Ubuntu 8.04) that I can't update, using Vim 7.1.138.
My vim installation is in /usr/share/vim/vim71/. /home/user/
My .vimrc file is in /home/user/.vimrc, as follows:
fun! MySys()
return "linux"
endfun
set runtimepath=~/.vim,$VIMRUTNTIME
source ~/.vim/.vimrc
And then, in my /home/user/.vim/.vimrc:
" =============== GENERAL CONFIG ==============
set nocompatible
syntax on
" =============== ENCODING AND FILE TYPES =====
set encoding=utf8
set ffs=unix,dos,mac
" =============== INDENTING ===================
set ai " Automatically set the indent of a new line (local to buffer)
set si " smartindent (local to buffer)
" =============== FONT ========================
" Set font according to system
if MySys() == "mac"
set gfn=Bitstream\ Vera\ Sans\ Mono:h13
set shell=/bin/bash
elseif MySys() == "windows"
set gfn=Bitstream\ Vera\ Sans\ Mono:h10
elseif MySys() == "linux"
set gfn=Inconsolata\ 14
set shell=/bin/bash
endif
" =============== COLORS ======================
colorscheme molokai
" ============== PLUGINS ======================
" -------------- NERDTree ---------------------
:noremap ,n :NERDTreeToggle<CR>
" =============== DIRECTORIES =================
set backupdir=~/.backup/vim
set directory=~/.swap/vim
...fact is the command syntax on is not working, neither in vim or gvim. And the strange thing is: If I try to set the syntax using the gvim toolbat, it works. Then, in normal mode in gvim, after activating using the toolbar, using the code :syntax off, it works, and just after doing this trying to do :syntax on doesn't work!!
I have the syntax files in both /usr/share/vim/vim71/ and home folders (in the home there's only a python syntax module). I've run sudo aptitude install vim as well and there's nothing do download, EXCEPT vim-gtk, since I was afraid of some kind of incompatibility.
What's going on? Am I missing something?
Let's break this down into something simple. Instead of trying to debug multiple possible points of failure (source, runtimepath), see if the simplest case works. Then, add back in each piece until something breaks.
First of all, make sure your ~/.vimrc/ and ~/.vim/.vimrc are checked into version control or save off a copy. Also, unless you've modified the original python syntax module for some reason, there should be no need to have it located in your ~/.vim directory.
Now, delete the contents of both .vimrc files and add only the following two lines to your ~/.vimrc file.
filetype plugin on
syntax on
Now, open up a new vim session with the file you're trying to syntax highlight. Does it work? I would expect this to work in most cases if the filetype is being detected properly.
:set filetype?
If the syntax highlighting isn't working and the filetype is correct there's something more wrong than just your .vimrc files. You could try removing your ~/.vim directory too to see if that's the problem.
I'm not sure why you're setting your runtimepath but when I check mine, it shows ~/.vim as the first entry (and there are a lot more directories than just VIMRUNTIME) by default so that line shouldn't be necessary.
:set runtimepath?
Also, VIMRUNTIME is misspelled. I expect this is your problem. If I use your set runtimepath from above, I lose syntax highlighting as well.
Hope this helps.
Ubuntu default install doesn't install all of vim.
sudo apt-get install vim
Try adding filetype plugin on before syntax on in your .vimrc.
I know how to set the initial window size in gVim, but how do I get it to automatically restore the window dimensions from last session? Is this even possible?
Edit: Corrected my answer. The mentioned winsize sessionoption only refers to the vim internal window layout, not the external dimensions.
If you use
:mksession
and load the session on vim startup with
gvim -S Session.vim
you can include the window position and size into the session by including winpos and resize in the sessionoptions, see
:help 'sessionoptions
With autocommands you could even automate the saving and restoring of the session on Vim entry and exit.
These lines save and restore just the position and size:
set sessionoptions+=resize,winpos
autocmd VIMEnter * :source C:/session.vim
autocmd VIMLeave * :mksession! C:/session.vim
Additionally:
In your .vimrc:
set ssop+=resize,winpos,winsize,blank,buffers,curdir,folds,help,options,tabpages
Then, use the script from this article. It works beautifully!
I had the same question, and to expand on the above answer, you can simply add the following to your .vimrc to get the behaviour you want:
set sessionoptions+=resize,winpos
see :h ssop
gvim -geom 85x55
as in, putting this in your .bashrc:
alias G='gvim -geom 85x55'
If you just want vim to open to the same size every time, you can edit your user's vimrc in C:/Users/<yourUserName>/_vimrc (this is preferred to editing the system _vimrc in your vim installation folder)
to include the line set lines=<yourHeight> columns=<yourWidth>