How to keep previous directory in CtrlP? - vim

Using the CtrlP plugin, I'm typing .. several times to get to the root directory of a project, then perform the search from there.
However after I reopen CtrlP it still searches in the directory of the current file.
How can I get it to stick to the directory that I originaly set ?

By reading its documentation, of course.
If you want CtrlP to always open in your project's root directory, if applicable, just add this line to your ~/.vimrc:
let g:ctrlp_working_path_mode=2
But you could also use both :CtrlP to browse in the current directory and :CtrlpRoot to browse in the root of your project.
Or simply use :CtrlPLastMode to launch CtrlP in… the last mode.
If your project doesn't fit CtrlP's definition of a project, a simple mapping could be enough:
nnoremap <key> :CtrlP /path/to/project<cr>
or you could use this option:
let g:ctrlp_root_markers = ['']
edit
My answer was based on the version of CtrlP currently installed on my machine.
The latest version adds an optional argument to :CtrlPLastMode: --dir which does exactly what you are looking for:
:CtrlPLastMode --dir
The g:ctrlp_working_path_mode values are different, too. I believe r is the equivalent of 2.

Related

How to install twig.vim in the .vimrc file for Vim 8.1

I'm trying to get this installed in my vim for ubuntu:
https://github.com/nelsyeung/twig.vim
I downloaded the files to ~/.vim folder, but there are no instructions on what I need to put into the .vimrc file to get it activated. What steps am I missing?
I downloaded the files to ~/.vim folder,
No. If you want to use Vim new integrated plugins management, first create the pack directory with a dedicated subdirectory of your choice (let's call it git-plugins but it's really own to you and depend how you want to have things organised)
mkdir -p ~/.vim/pack/git-plugins
In that location, create one of these directories:
start for plugins you always want available when you launch Vim
opt for plugins you want to activate and deactivate manually
Last, there will be a directory for the plugin itself. So, here, you have to download the files into let's say ~/.vim/pack/git-plugins/start/twig/
instructions on what I need […] to get it activated.
Now, launch vim and type the following command:
:packloadall
Check the included manual with
:h packl
This plugin has no doc to integrate into that system. But for general cases, put the following in your ~/.vimrc, after all internal setting and before plugins dedicated settings.
packloadall
silent! helptags ALL

vim: change pwd while working with cscope

I'm currently working on project using vim+cscope.
Sometimes, to make some code-exploring tasks easier I use :cd command to navigate to a specific folder withing the project. But then, if i want to issue some cscope command such as Ctrl-] or :cscope find it won't work before i change back to my project's root directory. I understand that's because cscope just tries to open the path as it is written in the cscope_db file without any sophistication.
So how do i make cscope "remember" my project's root directory so wherever i am it will always know to open the right path?
Apparently :set csre did that for me:
basename of cscope.out location (usually the project root directory) will be used as the prefix to construct an absolute path.
Due to some misconfiguration I missed it.

:vsplit autocomplete not working with /django/ directory in VIM

Normally if I type :vsplit /path/to/some/directoryTab, the available directories will autocomplete.
After doing a reinstall of VIM, there is one directory that now will not allow autocomplete, and I can't figure out why. The directory is ~/Sites/django/. Once I type ~/Sites/, Tab will show me drupal and apps directories, but will not show django. If my working directory is inside this django directory, :vsplit won't let me autocomplete either.
I did a ls -haltr on the directory and it looks the same as the others inside the ~/Sites/ directory.
Also, when I use the CtrlP plugin inside this directory, I get the error "==NO ENTRIES==". In other places, CtrlP works fine.
Why might this be happening and how can I fix it?
The directory is getting ignored because it has /django/ in it's path...which was set by my Python linter. The linter causes Vim to ignore /*django*/. To see this, use set wildignore to see what directories are getting ignored.
I just changed the directory to /dj/ and it works fine.
I could have also changed the wildignore directories by using set wig-=my_directory command.

VIM: Unable to uninstall Latex-Box plugin with Vimball

According to documentation, vimball uninstall should be a very simple process of typing in :RmVimball LatexBox
However, I get the error message
vimball (RmVimball) unable to find in .VimballRecord
I'm pretty sure I'm typing in the right prompt because LatexBox.vmb is the file I ran :so % on to install the plugin.
The Vimball documentation (http://www.cs.csubak.edu/docs/vim/pi_vimball.html) states:
:RmVimball removes all files generated by the specified vimball
(but not any directories it may have made). One may choose a path
for de-installation, too (see |'runtimepath'|); otherwise, the
default is the first existing directory on the |'runtimepath'|.
And indeed my .VimballRecord exists in the first existing directory of the output when I type in :echo &runtimepath . I opened up the .VimballRecord and it says
LatexBox.vmb: call delete('C:\Program Files (x86)\Vim\vimfiles/ftplugin/tex_LatexBox.vim')| ...
which seems to confirm that LatexBox is the correct plugin name. I'm very confused where the error is coming from. Otherwise -- How can I remove this plugin manually? (I'm concerned that going through and deleting files in the ftplugin folder is not thorough)
To uninstall a vim plugin is really easy, because there're no hidden stuff.
Go into C:\Program Files\vim\vimfiles(depending on your system)
Find out all files about LatexBox
Delete them.
Make a backup of vimfiles folder before deleting files.
If something goes wrong, you have a change to recover.
Update:
Answer you question about :helptags command:
When you install a plugin, it may contains help files(for example latexbox.txt).
It was often install in C:\Program Files\vim\vimfiles\doc directory (I will call it doc from now).
This direcotry may contains other help files for other plugins.
Notice there's a tags file in this doc directory. The tags file is used for jumping to location when you press Ctrl-] on a word.
Don't worry if doc\tags not exist.
You can use :helptags C:\Program Files\vim\vimfiles\doc to generate it.
When you install a plugin via vimball (which is just a vimscript to help you creating files/directories),
The vimball will create latexbox.txt in doc directory,
and run :helptags command to update the tags file automatically.
So, when you manually delete doc\latexbox.txt,
the tags file still contains infomatation about latexbox.txt.
Just run :helptags path\you\want\to\sync command again to get doc\tags synchronised.
Been there. The problem is that Vimball version (v31) that comes packaged with Vim is obsolete and does not support .vmb files. Check 1 for the latest Vimball version and you will be alright.

Plugins in gVim not working

I need help in installing some of the popular plugins in Vim. I just started learning this editor and is very excited to use the popular plugins. I'm using gVim in Windows XP and have extracted the .vim files and copied them to the Program Files folder of Vim.
Inside my "F:\Program Files\Vim" folder, there are exactly two folders the "vim73" and the "vimfiles" folder. I put the .vim files (EasyMotion.vim) into the "plugin" folder inside the "vimfiles" folder.
When I run gVim, the plugins doesn't work, and in my case, the EasyMotion plugin is not working. I typed the "/w" to make the EasyMotion plugin work (as stated on its usage on its github account) and nothing seems to work.
Am I missing out something here? Are there extra commands to put in the vimrc file to recognize those plugins?
Cheers!
Never touch Program Files. There is a vim setting called 'runtimepath' (see the :help 'rtp') that says where Vim is going to locate the plugins. For each directory in the runtimepath, Vim will source every .vim file found in the plugin subfolder, and lookup for functions containing # in their names in the .vim files of the autoload folder. It will also lookup filetype plugins in the ftplugin folder when 'ft' is set.
Normally you should have %HOMEPATH%\Vim\vimfiles in your runtimepath (:echo &rtp to know). Unzip Easymotion there, NOT in Program Files.
Due to that structure, vim plugins mix up in the same 2-3 folders. However it is possible to install every plugin in its own subfolder if you play with runtimepath. The pathogen plugin is dedicated to that. It makes it possible to have every plugin in its own subfolder, and adds every plugin root folder to the runtimepath. The Readme is self-explanatory.
As #benoit said, you should never in general put files into your vim73 folder
(notable exceptions exist, but you'll know when you encounter them).
On windows, Vim searches for configuration files (those include _vimrc and your
plugins) in several directories, in a certain order. First it will look in
$HOME ... which is your c:\documents and settings\username\ folder
$VIM ... which is the folder where you installed or extracted Vim
$VIMRUNTIME ... which is your \vim73 folder ...
and so on ...
What this means? It means it will first look in $HOME before looking in let's
say, your Vim install folder. So it is a nice way of separating plugins which
you just want to test out before being sure you're gonna be keeping them.
For example, you could organize your Vim related files in this manner:
- install vim to c:\vim or c:\program files\vim\
(vim's program files will go in \...\vim\vim73\)
- put your _vimrc in \vim\
- put your vimfiles in \vim\vimfiles\
- and put your temporary vimfiles in c:\documents and settings\username\vimfiles\
That way when you're done with them, you can just delete that last
\username\vimfiles\ folder.

Resources