Vim does not execute plugins in editor, only in application - windows

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.

Related

copy paste in iterm, vim

I use iterm in Mac as my command line terminal. In iterm I use tmux as the terminal manager. When I open my code files in Vim copying has become painful in this. To copy text in vim I need to hold "option" key and then select the text. When holding option there are multiple issues:
1) I am unable to scroll while in select mode
2) When I split my terminal into 2 panes, select using option copies across panes making it tough.
I am not sure about the reason for this issue and where to find a workaround. Could anyone help me with it?
You cannot depend on iTerm's clipboard support because it will not know anything about Vim's or tmux's splits. Use native Vim copy instead.
:help v
:help V
:help y
:help d
:help "*
:help clipboard
So e.g. in order to copy two lines, you can do "*2yy (to clipboard register, two line yank); or you can mark something using visual mode, then just "*y (to clipboard register, yank). If you want the clipboard register to be always automatically used unless another register is specified, you can add the following to your .vimrc:
set clipboard+=unnamed
Then a simple 2yy will copy two lines, and you can just paste it in iTerm or any other application.

Windows gVim 7.3 is creating unexpected folders when opening a file

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.

Need to re-edit .bash_profile but locked out because PATH is wrong

I just added an incorrect PATH line to my .bash_profile and now every command results in "command not found", include vim. How can I re-edit the file to make the correction?
Thanks!
Try specifying an absolute path to an editor:
% /usr/bin/vim ~/.bash_profile
On the Mac you can also use the open command to have the OS open a GUI-based editor of its choosing (or have you select one.) I believe TextEdit is the default for .bash_profile:
% open ~/.bash_profile
In the case command line tools won't work, files on most systems (eg. linux, osx, cygwin, etc) can be edited by non-command tools such as notepad. This tool, in contrast to Wordpad, is a plain text editor, while Wordpad is a word processor. In case some errors appear after using it, in the terminal simply runs:
dos2unix your-problematic-file
that should solve the problem.

Syntax highlighting in Vim before and after opening the same file in Xcode

When I create a file from within Vim, my syntax (for any language) is correctly highlighted.
Suppose I proceed to open that same file with Xcode, save, and then close the file. When I reopen that same file with vim, filetype is set to "conf".
This occurs consistently, regardless of the true filetype (I typically use php, python, hmtl, javastcript, c, etc.).
Why does vim's evaluation of a file's filetype change, aft*emphasized text*er opening the same file with Xcode?
I'm running Xcode on Lion.
Wile I can't say exactly why it is reverting to the "conf" filetype after Xcode saves it, you should be able to force it to whatever you want with a modeline for the filetype.
As an example, you would use
"# vim: set filetype=python :"
The documentation is not the clearest, but you can wrap the modeline in your target language's commenting symbols (//, /*, #, <!--, etc) and it will register. Check that it loaded the desired filetype with "set filetype" (no argument) and it will tell you what is currently used.
You my also want to ensure filetype detection is turned on by putting "filetype on" in your .vimrc file.

Vim: Change start up directory?

When I start GVim and start writing my little program I'd like to save the file to the Desktop but it seems that Vim is starting the command line in:
C:\Windows\System32
How would I go about changing that to:
C:\Users\Casey
so then I could just:
:w Desktop\my_program.py
Assuming you're starting gvim from an icon/shortcut in Windows (from the kind of paths you supply), you can change the starting directory (completely independent from the fact that it IS gvim: it would be the same from any other app!) by editing the "starting directory" property of that Windows icon/shortcut.
Within vim, you can change the current directory with the :cd command:
:cd c:\users\casey
I found this way to be better:
Open gVim
:cd $vim
:e _gvimrc
Add the following line:
:cd c:\users\user\desktop\
I found that :Ex is slow on large directories like c:\windows\system32\ (where gVim usually starts).
Also, here is my full _gvimrc in case anyone is interested. I prefer Consolas for coding. The tabstop setting helps when coding especially in Python, and Ctrl+Tab/Ctrl+Shift+Tab is great for switching between buffers:
set guifont=Consolas:h12:cANSI
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
map <C-Tab> :bnext<cr>
map <C-S-Tab> :bprevious<cr>
:cd c:\users\user\desktop\
How about changing your starting position?
vim icon -> right click -> property -> shortcut -> Start in -> your path you want to change.
but it works perfectly.
I think :cd yourpath also works. but it will change when you don't want to change.
Use :cd c:\users\casey,
after that save into session (in gVim there is button up and down in red, click on it and save as mySessionProject.vim). Next time you need to go to that directory, open that session (you can also use :source mySessionProject.vim)
for command line:
:mksession! yourdir/yourVimConfName.vim
to load
:source yourDir/yourVimConfName.vim
I found the following to be very useful. I am on Windows 7 and vim 7.3.46, and am using gVim.
I edited startup settings, which wound up altering the _vimrc in c:\Users\me\.
I also tried using :version and editing the _vimrc files I found at $VIM, as well as the _vimrc I found at c:\windows\system32.
Editing those files to include :cd c:\Users\me did not result in my default startup directory changing after starting vim. I wanted my default directory to be c:\Users\me\, and editing c:\Users\me\_vimrc achieved that. That is I entered
:e $MYVIMRC
and added
cd c:\Users\cnorton.Arlington1\
to that file.
Just to to put this up incase anyone needs it:
vimrc accepts enironmental parameters. you can put cd $USERPROFILE in your vimrc
Use this mapping in your .vimrc file
:cd $USERPROFILE\Desktop<cr>
or the same shorter
cd ~\Desktop<cr>
A mapping that also displays afterwards the path instead of the command
nmap <leader>d :cd ~\Desktop<cr>:pwd<cr>
Inside init.vim, I use:
lcd $HOME/Projects

Resources