Skip to content

Commit

Permalink
Answer the question about accessing files over scp or ftp. (#1259)
Browse files Browse the repository at this point in the history
* Answer the question about accessing files over scp or ftp.

* Minor formatting change to README.

* Update version number in Change Log.
  • Loading branch information
PhilRunninger authored Sep 7, 2021
1 parent 0e71462 commit e5f24e2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
-->
#### 6.10
- **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259)
- **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243)
- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249)
- **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236)
Expand Down
32 changes: 32 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,35 @@ let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = ''
```
The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details.
### Can NERDTree access remote files via scp or ftp?
Short answer: No, and there are no plans to add that functionality. However, Vim ships with a plugin that does just that. It's called netrw, and by adding the following lines to your `.vimrc`, you can use it to open files over the `scp:`, `ftp:`, or other protocols, while still using NERDTree for all local files. The function seamlessly makes the decision to open NERDTree or netrw, and other supported protocols can be added to the regular expression.
```vim
" Function to open the file or NERDTree or netrw.
" Returns: 1 if either file explorer was opened; otherwise, 0.
function! s:OpenFileOrExplorer(...)
if a:0 == 0 || a:1 == ''
NERDTree
elseif filereadable(a:1)
execute 'edit '.a:1
return 0
elseif a:1 =~? '^\(scp\|ftp\)://' " Add other protocols as needed.
execute 'Vexplore '.a:1
elseif isdirectory(a:1)
execute 'NERDTree '.a:1
endif
return 1
endfunction
" Auto commands to handle OS commandline arguments
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc()==1 && !exists('s:std_in') | if <SID>OpenFileOrExplorer(argv()[0]) | wincmd p | enew | wincmd p | endif | endif
" Command to call the OpenFileOrExplorer function.
command! -n=? -complete=file -bar Edit :call <SID>OpenFileOrExplorer('<args>')
" Command-mode abbreviation to replace the :edit Vim command.
cnoreabbrev e Edit
```

0 comments on commit e5f24e2

Please sign in to comment.