kien / ctrlp.vim

Fuzzy file, buffer, mru, tag, etc finder.
kien.github.com/ctrlp.vim
7.26k stars 676 forks source link

Open new window from netrw buffer #28

Closed fomichev closed 12 years ago

fomichev commented 12 years ago

Hi,

When I run vim via vim . to open it with the current directory listing and then ctrl-p to another file, the new split window is opened instead of using the current one.

I explicitly set the following options:

let g:ctrlp_split_window = 0
let g:ctrlp_open_new_file = 0

After some digging in the code I found that netrw sets noma, nobl and bf=nofile. This "breaks" s:normcmd call in the ctrlp#acceptfile and executes bo vne ... instead of bo e ....

Maybe there is some work around for such an issue? Netrw lets me redefine its buffer settings via g:netrw_bufsettings but honestly I don't want to see its buffers in the 'ls' and make them modifiable.

I'd appreciate your help, thanks!

kien commented 12 years ago

The s:normcmd() is there to do exactly that, preventing the new buffer being opened in windows created by plugins. These windows are often small or very small (NERDTree, Gundo, MiniBufExpl ...) and user obviously doesn't want them to be replaced by mistake.

But it looks like netrw is an exception, so I think I'll add an option to force :e for some plugins.

kien commented 12 years ago

Just added an option for this. You can use this to add some exceptions to s:normcmd():

let g:ctrlp_dont_split = ['Netrw']

Let me know how that works for you.

fomichev commented 12 years ago

Nope, it doesn't work. The problem here is that netrw buffer is not named 'Netrw'; its name is path that's currently shown.

kien commented 12 years ago

I extended the option to include filetype as well. Let me know how this works:

let g:ctrlp_dont_split = 'netrw'
fomichev commented 12 years ago

Yes, now it works! Thank you for such a nice fix and quick response!