You can save and restore the current tab around the :tabdo operation. You can use tabpagenr() to get the position of the current tab and later you can pass that number to :tabnext to change back to this tab. This is better done in a function, since you can easily run multiple commands and also use a local variable to store the current tab number.
To make something work in visual mode, you need a visual-mode mapping (usually :x[nore]map). In this case, we need to do these steps
Save the register
Restore the selection and do the cut (x or d or whatever)
Restore the register if whitespace
This is reminiscent of your original function, so let's modify it to take a visual arg: if truthy, do gv before ...
Simply !start %:p:h should be enough.
However, normall you'd better make use of some builtin "file explorer" plugin. Be it standard netrw or something else. There's rarely a benefit in spawning a full-featured Windows Explorer window.
I use following to open directory where current file is and select it if possible:
"" Open explorer where current file is located
"" Only for win for now.
func! File_manager() abort
" Windows only for now
let path = substitute(b:netrw_curdir, &...
Since your command contains a dynamic element (IOW it's not made up entirely of static strings) you'll need to build it with :execute.
Assuming 'shell' and 'shellcmdflag' have the defaults for win32 (cmd.exe and /c, respectively) then this will work:
exe '!c:\windows\explorer.exe ' . expand("%:p:h")
If c:\windows is already in your PATH envvar ...
The file that is associated with the currently executing autocommand can be retrieved with this function call:
Somewhat contrived but easy to understand test...
autocmd BufWritePost * echom "I saved file " . expand('<afile>')
After loading this and running :w the message ...
Simply because a line break in the replacement component of the substitution command is represented by \r in Vim rather than \n...
Alernatively, you can use this:
Where the ^M is entered by typing Ctrl+V then Enter
See :h s/\r and :h s/<CR>
FYI using \n will...
insert a <NL> (<NUL> in the file) (does NOT break the ...
I recommend neovim-qt (GitHub - equalsraf/neovim-qt). It is plain vanilla, cross-platform, stable, actively developed, and fast enough.
To install on Mac using Homebrew:
brew tap equalsraf/homebrew-neovim-qt
brew install neovim-qt
To install on Debian/Ubuntu:
sudo apt-get install neovim-qt
Neovim-qt is included in Window's port of Neovim (by running nvim-...
I think you need to change
" Comment the line
execute 'silent s/\v^(\s*)/\1' . comment_leader . ' /'
" Comment the line
execute 'silent s/^/\1' . comment_leader . '/'
so that it substitutes at the beginning of the line rather than after any space. The uncomment pattern needs similar modifications:...