How to launch a program from NERDtree - vim

Whenever I try to launch a program from NERDtree it opens it for editing. What if I want to run the program instead? How can that be done?

Put cursor on executable file, press m to show menu, and press ! to launch.
You can also create own mappings for NERDtree, see example by: :h NERDTreeAddKeyMap

Related

Disable quiting when pressing `q` in NERDTree vim plugin

When I press q in the NERDTree window it quits. I would like to disable that behaviour.
I am using q to create a script when I need to make the same change to a lot of files. But I cannot start the script from the NERDTree window itself, because that quits it. Alternatively I would like to know how to start the q scripting with another command.

Vim: Close 1 file in a split view?

I'm currently learning vim using vimtutor but whenever I try to open vimtutor there's always a split screen view of the previous file like this:
How can I close the bottom window?
You can press 'Ctrl w w' to switch between the window panes. Switch to the second window pane and in normal mode, type :q and enter. This should close the bottom window.
The screenshot looks like an empty file on the bottom; and on the top, the vim help screen describing vimtutor. I think you must have typed vim on the command line (which launched Vim with an empty file), then :help vimtutor (which brings up a Vim help page about vimtutor).
That would be why ctrl-w w and :q closed the whole vim editor. The ctrl-w w put you back in the new blank file; and :q executed a "quit" command.
Instead of launching vim that way, on the command line try typing vimtutor.
The top window has file type of "help" (this is shown in its status line). Help is normally viewed in splits, not as a single window. When other window is closed with :q and "help" becomes the last one, vim closes the whole tab or even the app. So don't do this.
If you seem the window is too small then maximize it vertically by pressing ctrl-w followed by "underscore". But it is really a matter of habit. No one bothers doing tab help vimtutor or such. Split view is just okay. So the best advice for you is "to comply".
You are not "using vimtutor"; you are using Vim and viewing the help for vimtutor.
What you get is absolutely normal and expected: the help is always displayed in a window so that you still have the thing you are working on visible while you check the documentation.
To actually use vimtutor, quit Vim and, when you are back at your shell, run the following command:
$ vimtutor
To keep only the current window press Ctrl+w+o. Mnemonic "only"

How to emulate <F11> press on startup in vimrc

<F11> makes it full screen in ubuntu (I changed the settings and chose show the menus for a window In the window's title bar rather than in the menu bar) and hides the global menu panel (at the top with the battery and wifi symbols). I didn't want to press <F11> every single time I opened gvim so what do I have to write in .vimrc for this?
The mappings and Vimscript commands that you can put into your ~/.vimrc are only for scripting Vim itself; you cannot directly control your environment with it. The only way is through launching an external command (via :! or :call system(...), for example wmctrl with the right arguments. Alternatively, you could modify the shortcut / command that launches GVIM to include this maximization, so you don't need to "break out" from inside Vim.
I'm using the :Fullscreen command of the shell.vim - Improved integration between Vim and its environment plugin; it works well on Windows and Gnome. You can launch that automatically by putting Fullscreen into your ~/.gvimrc.

What is the Vim command to quit all open windows?

:q only closes the current window. If you are using tabs or split windows, you need to do :q for all of them. Also, plugins like NERDTree and MiniBufExpl have their own windows, which need to be closed individually.
Is there a command to quit all these open windows and quit Vim in a single stroke? However, if there is some buffer or window with unsaved changes, I should be asked to save it or not. Any command to achieve this?
I hope this is not a strange request, because this is how most non-Vim editors with tab or splits work.
You can quit all loaded and open buffers, splits and tabs with:
:qa
If you want to quit without saving:
:qa!
You could assign a mapping to do this with a single stroke, this assigns the comma to quit everything without prompting to save:
nnoremap , :qa!<CR>
:wqall writes before closing, that might be useful.
Type :he :qa in vim for more info
you can user the
:qall
:qa
quit all the tabs opened
then you can use the command
:tabo
quit all other's tabs
if your's vim is not tabs you can use
:on
quit all windows

Using :Vexplore effectively

So, the :Vexplore command in vim opens a nice little directory browser to the left.
But how do I then open a file from that side-pane into the main window on the right?
One would assume there's a simple mapping for it, but I can't seem to find it.
I think you want o or P
Also, have a look at the documentation, e.g.
:he netrw-p11
It turns out it's just a single line in .vimrc:
let g:netrw_browse_split=4 " Open file in previous buffer
Source: http://vimcasts.org/episodes/the-file-explorer/#comment-45366660
I'm sure what you're looking for is this:
:Vexplore!
This is the same command you would use to navigate to different windows in Vim (like quickfix window, or different split), everything is explained in
:help windows.txt
But to answer to your question directly:
CTRLwCTRLh to move to the left window
CTRLwCTRLl to move to the right window
then Enter to select the file you want to open.
You might want to read :help netrw as well
The latest netrw plugin (up to v153f) now provides the :Lexplore command, which opens an explorer on the right hand side of the vim display. It sets g:netrw_chgwin so edits occur in the window to the right of the netrw window. You can get it from http://www.drchip.org/astronaut/vim/index.html#NETRW .

Resources