When I happened to issue "mo" in NERDTree, it open a file in default application
which is awesome, but, I cannot not refer to a documentation for such an operation.
Where could I find where the "mo" is defined?
It is not in "help".
Here is my vimrc
> execute pathogen#infect()
nnoremap <silent> <F5> :NERDTree<CR>
"syntax enable
set background=dark
filetype plugin indent on
syntax on
"NERDTree Config
autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
map <leader>r :NERDTreeFind<cr>
"Edit process
set number
"set ignorecase
"set smartcase
set spell spelllang=en_us
"Switch between the tabs
map <C-l> :tabn<CR>
map <C-h> :tabp<CR>
map <C-n> :tabnew<CR>
It seems that m is mapped to the menu:
call s:initVariable("g:NERDTreeMapMenu", "m")
It doesn't seem to be a default menu-item, since the NERDTree documentation states the following:
A programmable menu system is provided (simulates right clicking on a
node)
one default menu plugin is provided to perform basic filesystem
operations (create/delete/move/copy files/directories)
There's an API for adding your own keymappings
The last item is your key here, there is an API which allows you and other plugins to expand the menu:
call NERDTreeAddMenuItem({
\ 'text': 'e(x)ecute',
\ 'shortcut': 'x',
\ 'callback': 'NERDTreeExecute' })
This is an example from this plugin:
https://github.com/ivalkeen/nerdtree-execute/blob/master/nerdtree_plugin/execute_menuitem.vim
So I bet you have another Plugin installed which maps o as shortcut in the NERDTreeMenu.
Related
I'm currently working on my .vimrc, and theres is something i don't know about.
I made this line :
"=====[ On vim load, toggle NERDTree and switch to file ]=====
autocmd VimEnter * :NERDTreeToggle | wincmd l
Which open nerdtree on load when i open vim, then switch to the main buffer after.
This work nice, but i want this cmd only when I open a folder :
vim .
But when I'm working on file only I don't need it.
vim mytext.md
I'm looking for a condition on my rc file, but I don't find it. Something like :
"=====[ On vim load, toggle NERDTree and switch to file ]=====
if typefile != 'file'
autocmd VimEnter * :NERDTreeToggle | wincmd l
endif
So if you have an idea on this...
thanks for all
This should work:
augroup vimrc
autocmd!
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) | NERDTreeToggle | wincmd l | endif
augroup END
But I'm sure there's already a definitive solution somewhere on the internet.
See :help argc(), :help argv() and :help isdirectory().
I`m using following VIM settings for folding:
highlight Folded guibg=black guifg=#524A4D
set foldmethod=syntax
I`m also using Powerline plugin:
Bundle 'Lokaltog/vim-powerline'
I would like to save my foldings, so i found this two lines of code:
au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview
But after that my powerline status vanish after saving.
How to compare this three things.
I created screencast to show exactly whats going on:
http://screencast.com/t/ZnXTxdAVUZse
I think it is conflict between Powerline and mkview. So is then a chance to save foldings in other way??
The issue you have created on Github is likely to be more useful than this question here but I think your issue could be related to this other one.
You should remove the highlight Folded guibg=black guifg=#524A4D from your vimrc and delete the session files.
I found a answer:
set viewoptions-=options
augroup vimrc
autocmd BufWritePost *
\ if expand('%') != '' && &buftype !~ 'nofile'
\| mkview
\| endif
autocmd BufRead *
\ if expand('%') != '' && &buftype !~ 'nofile'
\| silent loadview
\| endif
augroup END
I am trying to setup NerdTree on Unix. When I open gvim editor it displays the file explorer bar on the side. However, I am not able to click and open files nor use the vim keys. Not sure what's going on here.
I have the following lines in my vimrc for NerdTree setup:
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
nmap <silent> <c-n> :NERDTreeToggle<CR>
let g:NERDTreeWinSize = 30
Any ideas? THanks.
In my system, nerdtree is easy to use.
just delete
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
nmap <silent> <c-n> :NERDTreeToggle<CR>
let g:NERDTreeWinSize = 30
and try in cmdline :NERDTreeToggle
and then map the cmd.
Does someone know how to force .vimrc to auto-open NERDTree each time vim is invoked? The operation system is *nix.
au VimEnter * NERDTree
in your vimrc should do it
:he autocmd.txt for background
You can also only open Nerd Tree when there was no file on the command line:
function! StartUp()
if 0 == argc()
NERDTree
end
endfunction
autocmd VimEnter * call StartUp()
Taken from a blog post by Ovid.
One liner to open NERDTree when no file argument provided would be
autocmd vimenter * if !argc() | NERDTree | endif
OR
au vimenter * if !argc() | NERDTree | endif
The above code just checks if no argument is provided then open NERDTree.
Building on #zoul's answer, I in my case I wanted NERDTree to be open by default if I specify a directory or if I specify nothing, and not be open if I specify a single file, so I ended up with:
function! StartUp()
if !argc() && !exists("s:std_in")
NERDTree
end
if argc() && isdirectory(argv()[0]) && !exists("s:std_in")
exe 'NERDTree' argv()[0]
wincmd p
ene
end
endfunction
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * call StartUp()
If you are looking for a way to have a persistent NERDTree, that remains even when you open new tabs, you'd better use jistr/vim-nerdtree-tabs and add in your .vimrc :
let g:nerdtree_tabs_open_on_console_startup=1
The package is not maintained anymore, but it works and I don't know any equivalent.
In your vim config file (I use nvim, so for me its in ~/.config/nvim/init.vim), Add the line anywhere in the file:
au VimEnter * NERDTree
Is it possible to open NERDTree in every tab with pressing t or T in NERDTree, if yes, How?
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
edit: The above command seems to open the new tab in NERDTree's buffer. Instead use this as mentioned by wejrowski in the comment below :
autocmd BufWinEnter * NERDTreeMirror
I wrote a vim plugin that does this and also adds some goodies on top (i.e. keeps all trees in sync, ensures meaningful tab captions - not captions like 'NERD_tree_1' etc.).
It's here on Github: https://github.com/jistr/vim-nerdtree-tabs
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
autocmd VimEnter * wincmd w
This one is a little better than Dustin's one because it places the cursor directly on the file you are intending to edit for quick edits. Thanks dustin for the original example ^^
A better solution is to open NERDTree only if there are no command line arguments set.
" Open NERDTree in new tabs and windows if no command line args set
autocmd VimEnter * if !argc() | NERDTree | endif
autocmd BufEnter * if !argc() | NERDTreeMirror | endif
NERDTree is e.g. not helpful if you do a git commit or something similiar.
This is probably not the best way, but if you edit plugin/NERDTree.vim and change this:
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>openInNewTab(0)<cr>"
to this:
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>openInNewTab(0)<cr>:NERDTree<cr>"
it will alter the binding of 't' in the NERDTree view to first open the file and then open NERDTree. Note, that the NERDTree views will not keep in sync.
How about toggling it.
" in .vimrc
" NERDTree, Use F3 for toggle NERDTree
nmap <silent> <F3> :NERDTreeToggle<CR>
In OSX, you just need to fn-F3 to toggle NERDTree.
This problem was actually mentioned in the official Repository's Readme file including three situations related to opening NERDTree automatically:
How can I open a NERDTree automatically when vim starts up?
Stick this in your vimrc: autocmd vimenter * NERDTree
How can I open a NERDTree automatically when vim starts up if no files were specified?
Stick this in your vimrc:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
Note: Now start vim with plain vim, not vim .
How can I open NERDTree automatically when vim starts up on opening a directory?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.