NERDTreeToggle opens a second tree of parent directory that stays open after toggle (neovim/nerdtree) - nerdtree

When I toggle nerdtree it opens a tree of current working dir and a parent dir tree. If I toggle again the parent tree remains.
I only want the current dir tree to open and close.
I am using this config file that I found on youtube. https://gist.github.com/benawad/b768f5a5bbd92c8baabd363b7e79786f
Thank you in advance to anyone willing to leave comments :-)

You probably either found a solution already or quit using NERDTree, but if you still happen to be looking for a clue, try to get rid of the part below. I stumbled in that very repo and realised that such part was clashing with manual NERDTree toggling:
" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
" file, and we're not in vimdiff
function! SyncTree()
if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
" Highlight currently open buffer in NERDTree
autocmd BufEnter * call SyncTree()
In general, try to debug code by taking relevant parts away and readding them one by one until you figure out the non working bit.

Related

In ConEmu is it possible to get the command prompt all in one line?

Just started using conemu on windows again (after quite some time using other rubbish). Its great, but there is one element that really bugs me, that is the command prompt is always spread over two lines:
user.name#DESDAH181093 D:\user\workspace\
>
user.name#DESDAH181093 D:\user\workspace\
>
user.name#DESDAH181093 D:\user\workspace\
>
Can I get it so that this is compressed onto the same line, like this?
user.name#DESDAH181093 D:\user\workspace\>
user.name#DESDAH181093 D:\user\workspace\>
user.name#DESDAH181093 D:\user\workspace\>
I looked through the settings and did not spot anything obvious.
I saw this question: link, but I think I want to do the opposite and I can't find where anything like ${cwdfull}\n> is defined in the settings...
UPDATE
In addition to the answer of Max, here is what I really needed to change in the CmdInit.cmd file:
rem Carriage return and `$` or `>`
rem Spare `$E[90m` was specially added because of GitShowBranch.cmd
if "%ConEmuIsAdmin%" == "ADMIN" (
set ConEmuPrompt2=$S$E[90m$$
) else (
set ConEmuPrompt2=$S$E[90m$G
)
Where both ConEmuPrompt2 where:
ConEmuPrompt2=$_$E[90m$$
changed here ^
Make a copy of ConEmu\CmdInit.cmd file.
Replace I the copied file $_ with $S, save changes )
Utilize your modified file in the task {Shells::cmd}.
Save ConEmu settings.

How can I find the particular file in a Project/Folder in Sublime Text

I know that using ctrl+shift+f we can find the text in folder we want and simple ctrl+f will find the text in a opened file or we can right folder and click on a option Find in Folder... to search the text
I am looking for, how can I find the file in a Folder/Project.
You can use the Goto Anything feature (Ctrl+P on Windows and Linux, Cmd+P on macOS) and type the name of the file you're looking for. If there are multiple hits, you can select the appropriate file using cursor keys. It also supports powerful operators, that let you jump to specific parts inside a file.
Examples:
file.js opens that file
:100 jumps to line 100 in current file
file.js:100 jumps to line 100 in file.js
#loadFile lists all files with classes/functions named loadFile (shortcut: Ctrl+R, Cmd+R on macOS)
file.js#loadFile jumps to a loadFile() in file.js
This can be done using:
Windows: Ctrl + P
Mac: Cmd + P
It works much like ItelliJ's Shift - 2 times, with a faster and accurate prediction.

How to (easily) get current file path in Sublime Text 3

How to (easily) get current file path in Sublime Text 3
I don't often use ST console (I used it only once to install package manager), but I suppose it could be good way to :
get current file path like some kind pwd command.
But it doesn't work.
Does anyone know an easy way to get current file path?
to clipboard : better not a strict objective in the answer
not necessary by ST command, maybe package?
Right click somewhere in the file (not on the title tab) --> Copy file path
If you don't want to use the mouse, you could set up a keyboard shortcut as explained here https://superuser.com/questions/636057/how-to-set-shortcut-for-copy-file-path-in-sublime-text-3
To easily copy the current file path, add the following to Key Bindings - User:
{ "keys": ["ctrl+alt+c"], "command": "copy_path" },
Source
Key Bindings - User can be opened via the command palette (command + p on OSX)
Easy to understand using image. On Right Click you will get this.
Transcribed code in image for convenience:
import sublime, sublime_plugin, os
class CopyFilenameCommand(sublime_plugin.TextCommand):
def run(self, edit):
if len(self.view.file_name()) > 0:
filename = os.path.split(self.view.file_name())[1]
sublime.set_clipboard(filename)
sublime.status_message("Copied file name: %s" % filename)
def is_enabled(self):
return self.view.file_name()... # can't see
Mac OS X - Sublime Text 3
Right click > Copy File Path
A lot of these answers involve touching the mouse. Here's how to do get the path without any mouse clicks using SideBarEnhancements
Install SideBarEnhancements using PackageControl.
Click super + shift + P to open the command palette
In the command palette begin typing path until you see File: Copy Path
Select File: Copy Path
Now the path to file you are working in is copied into your clipboard.
There is a Sublime Package which gives your current file location inside a status bar. I just cloned them directly to my /sublime-text-3/Packages folder.
git clone git#github.com:shagabutdinov/sublime-shell-status.git ShellStatus;
git clone git#github.com:shagabutdinov/sublime-status-message.git StatusMessage;
You have to check/read the description on GitHub. Even it is listed in package control it would not install properly for me. You can actually edit the shell output as you want. If you have the right skills with python/shell.
Looks like this (Material Theme)
If you're like me and always click on items in the sidebar just to realize that copying the path only works when clicking in the editor area, have a look at the SideBarEnhancements package. It has a huge bunch of options to copy file paths in a variety of different ways.
Installation is available via Package Control (despite the webpage only mentions installation via manual download).
Note: The package “sends basic, anonymous statistics”. The webpage explains how to opt out from that.
Go to this link. The code in the link is given by robertcollier4.
Create a file named CpoyFileName.py or whatever you like with .py extension.
Save the file in Sublime Text 3\Packages\User folder. Then paste the above given key bindings in your Preferences: Key Bindings file.
Now, you can use the specified key bindings to copy just filename or total (absolute) filepath.
Please note that the filename or filepath do contain file extension.
Fastest Solution ( No Packages Needed + Comprehensive ):
Folder Path:
Folder in "Sidebar"
Right Click
"Find In Folder"
"Where" field contains everything you need
File Path:
File in current "Tab"
Right Click
"Copy File Path"

vim - how to remove netrw?

I was testing https://github.com/skwp/dotfiles) and unfortunately it did install a lot of things I do not want.
For example, right now (with empty .vimrc) when I open vim I get
" ============================================================================
" Netrw Directory Listing (netrw v149)
" /Users/user/.vim/bundle
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec
" ============================================================================
thing. I am in the beginning of my journey with VIM so I don't know what is new and right now I don't want to use it.
I am on OSX Mavericks with home-brew installed. Still, I cannot find where is this coming from and how to remove it.
Look at the first few lines of $VIMRUNTIME/plugin/netrwPlugin.vim:
" Load Once: {{{1
if &cp || exists("g:loaded_netrwPlugin")
finish
endif
If you want to disable it, just add
let loaded_netrwPlugin = 1
to your vimrc file.
You can remove the commented section by adding let g:netrw_banner=0 to your .vimrc
Since netrw's pages recommend removing older versions of netrw before updating it, I wound up finding a different way from the answers posted here. This might be especially useful for those of you looking to remove netrw (that is, uninstall netrw) before upgrading:
Download https://www.drchip.org/astronaut/vim/vbafiles/netrwclean.vba.gz, which can also be found under the netrw heading at https://www.drchip.org/astronaut./vim/index.html#NETRW
Open vim and do :so netrwclean.vba.gz, giving the full path to wherever you saved the file if necessary.
:NetrwClean to remove user-local copies or :NetrwClean! to remove both user-local and centrally-installed copies of netrw. Note of course that you'll need the right system-privileges to touch the files that will be removed, so you may wish to start vim as root.
(Optional) download the new version of the netrw vimball and :so netrw.vba.gz to update.
I don’t think that this installed Netrw — it comes bundled with Vim. You can learn more about Netrw on its page at vim.org.
What you’re getting now is (as it says) Netrw’s directory listing, which enables you to navigate within a directory from inside Vim.
Just remove these files (from your vim installation e.g. /usr/share/vim/vim74) and it will be gone
plugin/netrwPlugin.vim
syntax/netrw.vim
autoload/netrw.vim
autoload/netrwSettings.vim
autoload/netrwFileHandlers.vim
nvim:
share/nvim/runtime/autoload/netrw_gitignore.vim
share/nvim/runtime/autoload/netrw.vim
share/nvim/runtime/autoload/netrwFileHandlers.vim
share/nvim/runtime/autoload/netrwSettings.vim
share/nvim/runtime/syntax/netrw.vim
share/nvim/runtime/doc/pi_netrw.txt
share/nvim/runtime/plugin/netrwPlugin.vim

How does .vimrc set its own filetype?

In response to this question on SuperUser, I wrote a small vimscript that will detect the filetype of a symbolic link and change the syntax highlighting:
au BufNewFile,BufRead * if &syntax == '' | silent! execute (':set filetype='.matchstr(resolve(#%),'.[^.]*$')[1:]) | endif
So if I open a symbolic link with no extension, it will look at the extension of the file it points to.
It works, but an unintended consequence is that now the syntax highlighting of my .vimrc file is gone. By default, my .vimrc file has vim syntax highlighting (:echo &syntax returns vim).
But when I add the above line, :echo &syntax returns vimrc (an invalid type).
I don't know why this is happening. Shouldn't &syntax=='' evaluate to false, and thus keep &syntax==vim? I suspect that my code is executing before the syntax highlighting is set to vim. But how (and when) exactly is the syntax highlighting set to vim for .vimrc? Additionally, how can I make my script behave the way it should?
Look in Vim's runtime area for filetype.vim. You can bring it up in vim with:
:e $VIMRUNTIME/filetype.vim
In my version, it looks like this line does the trick:
" Vim script
au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')
Perhaps you want to put your autocmd in ~/.vim/after/filetype.vim. I believe this will cause it to be registered after the system ones, and then &syntax should be set up correctly.
jszakmeister's answer diagnoses the problem accurately: filetype.vim sets the filetype for vimrc.
An alternative solution though, to keep everything contained in in your .vimrc file, is to use:
au BufNewFile,BufReadPre * if &syntax == '' | silent! execute (':set filetype='.matchstr(resolve(#%),'.[^.]*$')[1:]) | endif
Note the change from BufRead to BufReadPre. The change causes this line to execute before filetype.vim. The syntax will be changed to vimrc, but then subsequently changed to vim. The upshot is that the script works as it should, but syntax highlighting for vimrc is preserved.
When the current file is ~/.vimrc, this part of your code
matchstr(resolve(#%),'.[^.]*$')
returns your file name: .vimrc.
I have no idea how you could imagine that /home/username/.vimrc would produce vim.
This is rather obviously a bad approach for the problem you tried to solve but there's no bug: you get exactly what you ask for. Using the filename/extension for filetype can't work reliably (js vs javascript, py vs python…).
You will probably need a filename/filetype list or many if/elseif if you want your code to do what you want.
See :h syntax-loading.

Resources