New answers tagged

1

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. function! ...


1

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 ...


0

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.


0

If you are using gvim, you can simply type :browse e in command mode you will have a mini-file explorer opened with current directory


1

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 if has("win32") if exists("b:netrw_curdir") let path = substitute(b:netrw_curdir, &...


1

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 ...


0

The file that is associated with the currently executing autocommand can be retrieved with this function call: expand('<afile>') Somewhat contrived but easy to understand test... augroup AfileTest autocmd! autocmd BufWritePost * echom "I saved file " . expand('<afile>') augroup END After loading this and running :w the message ...


1

Simply because a line break in the replacement component of the substitution command is represented by \r in Vim rather than \n... :s/,/\r/gc Alernatively, you can use this: :s/,/^M/gc 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 ...


1

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-...


1

I think you need to change " Comment the line execute 'silent s/\v^(\s*)/\1' . comment_leader . ' /' to " 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:...


Top 50 recent answers are included