New answers tagged

1

This was changed in 8.1.2401; now a shell pipe character does not need to be escaped anymore inside an expression containing a quoted shell command after :cexpr and the five other variants: :cgetexpr :caddexpr :lexpr :lgetexpr :laddexpr Before the patch, an unescaped shell pipe would raise E115 and E116: $ vim -Nu NONE :cexpr system('grep -Rn grail '..$...


0

If by external command you do mean shell commands then you can try using system function :h system(): No output (on Windows) let s:output = system("title") if s:output != '' echom s:output endif Output let s:output = system("date") if s:output != '' echom s:output endif


2

Prior to version 8.1.0271, in order to preview searches in this way you have to adjust your workflow slightly. First, set up your regular expression by using a normal search, during which highlighting will be active: /regular<CR> Then, you can re-use the regular expression from your search command by leaving the field blank in your substitute ...


6

Normal mode is the mode you are in when you start Vim and the mode you should spend the most of time in. From this mode you can easily invoke other modes (v for visual, i for insert, : for command line and so on). Everything you press in normal mode can be some sort of command. dd? It's a command saying "delete current line". Hence command mode. In command ...


6

: is a normal-mode key-sequence (command) that makes a switch into one of command-line submodes. From :h : Command-line mode is used to enter Ex commands (":"), search patterns ("/" and "?"), and filter commands ("!"). So in command-line mode : is just a prompt that shows you're allowed to input one Ex-command and then get back to the Normal mode (...


7

This is done by setting just two options: set is hls (incremental search and highlight all matches). Make sure you've also read the appropriate help topics, excerpted below: :h 'is' While typing a search command, show where the pattern, as it was typed so far, matches. The matched string is highlighted. If the pattern is invalid or not found, ...


2

I guess your motivation of clearing the undo information on writes is to avoid going beyond the saved buffer state when undoing many steps (uuuu...). I personally use a different approach: I've tweaked the u command to stop and beep once when reaching the saved buffer state. I need to u once more to go beyond. My customization integrates with the repeat.vim ...


3

As you're expressly using :edit in order to reset the undo information, you could follow :help clear-undo to do this without :edit. I would define a custom :Write command that combines both: command! -bar Write \ write | \ let old_undolevels = &undolevels | \ set undolevels=-1 | \ exe "normal a \<BS>\<Esc>" | \ let &undolevels = ...


1

I'll let @IngoKarkat write the answer that solves your real problem. However, for the benefit of future readers, you can also achieve what was originally requested by saving the view before executing :edit and then restoring it afterwards: :let v = winsaveview() :edit :call winrestview(v)


Top 50 recent answers are included