New answers tagged

0

Here is a plugin-less solution that I personally use and think works very well: set wildcharm=<C-z> cnoremap <expr> <Tab> getcmdtype() =~ '[\/?]' ? "<C-f>i<C-n>" : "<C-z>" It makes <Tab> trigger Ctrl-f, enter insert mode, and start vim builtin completion if in search mode. Otherwise, it ...


4

The problem with pure regex based solutions, is that there would be a few false-positives, like in: /*bar*/ char const* p = "/*"; /* bar */ /// foo char const* e = "*/"; /* in strings would be matched as well. I though at first that we could get around it with [* and ]*, but unfortunately, they are also regex based. Though, we can ...


1

I already know but I searched the web and couldn't find the definitive answer for VIM (just every other regex language), and I won't remember this again in a week, so I am documenting it here. And the answer is... /\/\*\_.\{-}\*\/ Lemme break it down. To match the first \* you have to escape both the \ and the * so that's \/\* To match the end you have to ...


3

This will do that for you: :%s/\v^AAA,([^,]+)/AAA,0.05/ Explanation: %s/{pattern}/{string}/: for each line in the whole file (%) substitute a match of {pattern} with {string} (:h :s) \v: one of vim's four regex modes (:h /magic) ^AAA,([^,]+): match lines starting with AAA, followed by one or more characters that are not a comma AAA,0.05: the string to ...


2

bufdo runs a command (here, the ex command :/), so there's no real interactivity For a search over multiple files (or buffers), use :grep/:vimgrep. For example: :grep -R pat . " or :vimgrep /pat/ **/* " or whatever you need Then you navigate with the quickfix list (:help quickfix). Probably :cnext/:cprevious are useful, or :cwindow if you want to ...


4

gnd (or dgn) deletes the next occurrence of the last searched term (deleting at the cursor position if it matches the search). See :help gn. (The hlsearch setting is irrelevant to this command.)


2

:find uses regexes as the regular search does. If you look at :h /[] you'll see that using [] in a pattern allows to search for a collection: \_[] A collection. This is a sequence of characters enclosed in brackets. It matches any single character in the collection. Example matches ~ [xyz] any 'x', 'y' or 'z' [a-zA-Z]$ any ...


Top 50 recent answers are included