We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

0

Doing getchar(1) in loop is problematic https://github.com/equalsraf/neovim-qt/issues/605 I really suggest you to look at cli.py of leaderF for an implementation.


0

No need for a plugin, just apply the substitution command: :%s/(\(\([^()]\|\n\)*\))/[\1]/g Notes Supports multiple matches per line: (aa) (bb) -> [aa] [bb] Supports multi-line content: (aa \n bb) -> [aa \n bb] Supports nested parenthesis: ((aa)) -> ([aa]) Doesn't change unmatched characters: a) (b) -> a) [b] However it needs to be applied ...


0

First you must compile your doc with synctex option: To do reverse search add the following: # Adding reverse search between gvim and zathura set synctex true set synctex-editor-command "gvim --remote-silent +%{line} %{input}" to your zathurarc file (Usually it can be find in your $HOME/.config/zathura folder). You can jump to line 150 column 2 by running:...


-1

Add this macro to your .vimrc map #h :set hls!<CR> This will allow you to toggle hilighting with #h


0

You can write a macro that operates on the pattern you want and run it like 500 times. For instance I had a bunch of lines like this one: Vrvirksomhed.virksomhedMetadata.nyesteNavn.navn That I wanted to CamelCase, so i wrote this small macro: /\.xvU, and ran it until no more changes.


-1

As @AndyB said, you can substitute with this: :s/(\(.*\))/[\1]/ I would alter it slightly to this. I added a ? after the .* to make it non-greedy, which means it will try to find the shortest match, rather than the longest one. :s/(\(.*?\))/[\1]/ You will also have issues if you have a right parenthesis inside a string. Which is a more complex problem to ...


8

You can do it in a single substitute command like this :s/(\(.*\))/[\1]/ The \( and \) mark the regex subexpression that matches everything inside the ( and ) in the input line. In the replacement, the \1 stands for whatever the first (in this case the only) marked subexpression matched. In words you might describe the substitute command as: look for a "("...


2

If that your cursor is on the left brace that you want to change: %r]^Or[ If your cursor is on the right brace: %r[^Or] Basically, ask vim to find the matching brace, change it, then jump back to the first brace and change it too. If your cursor is near enough to one of the braces you want to change, then you can do much as the above but double the ...


14

With tpope/vim-surround, this is a simple cs)] away. cs is the "change-surrounding" operator ) is the "target" ] is the replacement


7

You can use this simple :s command (or better two :)) :s/(/[/g :s/)/]/g You can even do it in one run, you you define your replacements first like this: :let replace={'(':'[', ')':']'} :s/[()]/\=replace[submatch(0)]/g Here we first define a dictionary with the keys of what you want to have replaced. So we need a key ( with the value [ since that is the ...


2

There are a couple of ways to approach this, however each one has its own drawbacks: There is no really good way to re-format a list of strings programmatically according to a different textwidth value. Your current best chances are basically to set the 'textwidth' option and reformat using gq (this can be done in another window to leave the current option ...


1

You can use a :substitute command for this: :%s/\v ?(<bugs>)(.*)/\2 \1 :%s substitute / start of regular expression \v use very magic mode. This makes this regular expression a bit easier to read/write, because you don't need to use so many backslashes [SPACE]? an optional space (<bugs>) find the entire word bugs, and save it in capture group 1....


1

Not too hard, really, as such tasks can be translated into regexps in a very straightforward manner. :v/tt\|hh/s/\<\a\{4}\>/D/g :v/.../ for all lines NOT matching a pattern tt\|hh "tt" OR "hh" s/.../D/g substitute ALL matches on a line with "D" \<...\> "word" borders \a\{4} exactly four Latin letters Have no idea where to start. Read ...


2

:g/ \?\<bugs\>/normal! dgn$p Explanation: :g/.../ for all lines matching a pattern \?\<bugs\> an optional space followed by "bugs" (a whole word) normal! dgn$p delete last match; go to end of line; put last match there


Top 50 recent answers are included