Being new to vim I 'think' it seems related to when I have a file that I've edited but not saved. So for example:
I split a window.
Make some changed in the original window but don't save them.
Now work in the other window and eventually close it.
When I now use NerdTree or command-t it opens a new file in a split window.
IF I first save the other file in the original window and the close the split window... new windows opened from command-t or nerdtree open just fine.
What's interesting though is if I had never opened a split window, then behavior seems fine.... even if files aren't saved I simply get new buffers created in the original main window. (Maybe doing :q isn't really closing the split window? I'm still sort of new to vim so I could be doing something wrong.)
I guess I could just remember to always save files after using a split window and things will be ok. I'd still prefer that simply a new buffer is created in the existing window I have, even if the file there is dirty, instead of relying on an old split window position.
(By the way, Wincent I switched to your Command-T after trying FuzzyFinder - love Command-T MUCH more! One thing drove me crazy about fuzzyFinder was that if I was in the NerdTree window and then used fuzzyFinder - it would open up the stupid file right in the narrow NerdTree window. Yours does NOT behave that way and is awesome. Thanks.)
I attached my .vimrc (I know it's probably a mess so if something jumps out at you as being bad/crappy in ANY area feel free to correct me... I need to give it more attention:)
Also pasted it here if it's more clear:
http://pastie.org/1160737
-------
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
"set directory=/Users/rick/.vimbackups/
set backupdir=/Users/rick/.vimbackups/
set backup
"set nobackup
"if has("vms")
" set nobackup " do not keep a backup file, use versions instead
"else
" set backup " keep a backup file
"endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Make backspace and cursor keys wrap accordingly"
set whichwrap+=<,>,h,l
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
"map Q gq
vnoremap Q gq
nnoremap Q gqap
" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Set leader to comma
let mapleader = ","
"Set up commands for FuzzyFinder
"even though i have this plugin i'm using the the fuzzy_finder_textmate
"map <leader>b :FufBuffer<CR>
"map <leader>r :FufMruFile<CR>
"map <leader>f :FufFile **/<CR>
"map <leader>R :ruby finder.rescan!<CR>:FuzzyFinderRemoveCache<CR>:exe ":echo 'rescan complete'"<CR>
" a leading space allows a recursive search
"let g:fuf_abbrevMap = {
"\ "^ " : [ "**/", ],
"\ }
map <Leader>c :TComment<CR>
map <Leader>vf :RVfunctional
map <Leader>l :!ruby <C-r>% \| less<CR>
map <Leader>rm :Rmodel
map <Leader>rv :Rview
map <Leader>rc :Rcontroller
map <Leader>rvm :RVmodel
map <Leader>rsm :RSmodel
map <Leader>rvv :RVview
map <Leader>rsv :RSview
"map <Leader>n ,w,t
map <Leader>o ?def <CR>:nohl<CR>w"zy$:!ruby -I"test" <C-r>% -n <C-r>z<CR>
map <Leader>p :set paste<CR>i
map <Leader>r :e doc/README_FOR_APP<CR> " Edit the README_FOR_APP (makes :R commands work)
map <Leader>f :!ruby -I"test" %<CR>
map <Leader>u :Runittest
map <Leader>vu :RVunittest
map <Leader>su :RSunittest
map <Leader>w <C-w>w
" nerd tree shortcut
map <leader>n :NERDTree<CR>
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
" autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
"set expandtab
set noexpandtab "real tabs
set tabstop=4
set shiftwidth=4
set softtabstop=4 "makes the spaces feel like real tabs
set nu
set hlsearch
set incsearch
set ignorecase smartcase
"set wm=8 "wraps margin 4 spaces from border
"set wrap linebreak textwidth=0
set nowrap
"nnoremap <C-n> :bnext<CR>
"nnoremap <C-p> :bprevious<CR>
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
colors desert
set guifont=Courier:h14
set ul=50
map <F3> :let &hls=!&hls<CR>
map <F2> <Esc>:1,$!xmllint --format -<CR>
"-- always encode to UTF-8 %!xmllint --format --encode UTF-8 -
"
" Make it way easier to switch windows (<leader>w)
nmap <leader>w <C-w><C-w>_
nnoremap <silent> <F7> :YRShow<CR>
let g:xml_syntax_folding=0
"this would set the current directory to whatever dir you are in,
"not good though when using fuzzy file search with nerdtree so
"turned off
"autocmd BufEnter * lcd %:p:h
let NERDTreeIgnore=['\CVS']
"bufkill notes:
"When you want to unload/delete/wipe a buffer, use:
" :bun/:bd/:bw to close the window as well (vim command), or
" :BUN/:BD/:BW to leave the window(s) intact (this script).
"basically: use :BW mostly
"
" Load matchit (% to bounce from do to end, etc.)
runtime! macros/matchit.vim
filetype on
filetype plugin indent on
augroup myfiletypes
" Clear old autocmds in group
autocmd!
" autoindent with two spaces, always expand tabs
autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
autocmd BufRead *.as set filetype=actionscript
"autocmd VimEnter * NERDTree
"utocmd VimEnter * wincmd p
" Note, perl automatically sets foldmethod in the syntax file
autocmd Syntax c,cpp,vim,xml,html,xhtml,mxml setlocal foldmethod=syntax
autocmd Syntax c,cpp,vim,xml,html,xhtml,mxml,perl normal zR
"au FileType xml setlocal foldmethod=syntax
"recognize groovy files by extension
au BufNewFile,BufRead *.groovy setf groovy
" Omni Completion
" *************************************************************
autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" May require ruby compiled in
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
augroup END
"syntax enable
set wildmenu wildmode=full
set autowrite
silent! ruby nil
:let g:LargeFile=1000
:let g:bufmru_switchkey = "<Space>"
:let g:bufmru_confclose = 0
:let g:bufmru_bnrs = []
:let g:bufmru_read_nummarks = 0
map <C-TAB> :bnext!<CR>
map <C-S-TAB> :bprev!<CR>
"this locked up mvim??? map <C-\> :b#<CR>
set tags=./tags