How to delete all lines matching a pattern and a line after in Vim?
You can use :g/word/normal 2dd This finds all instances of word and then executes the command after it. In this case it executes 2dd in normal mode
You can use :g/word/normal 2dd This finds all instances of word and then executes the command after it. In this case it executes 2dd in normal mode
Easier way is to just external command as a filter for a selection. e.g. Make a selection Type :!python -m json.tool
After @joe’s answer, Jared Parsons created the great VsVim. It’s been featured on Visual Studio Gallery. It’s a ready extension package. I downloaded it, ran the file and it worked out of the box. It’s free, too.
Specifically for subsitutions: use & to repeat your last substitution on the current line from normal mode. To repeat for all lines, type :%&
I think this is operating system independent: if !isdirectory(“/my/directory”) call mkdir(“/my/directory”, “p”) endif
I just keep the keyboard with US layout when coding and only switch to local layout (italian) when writing text that requires accented letters or other language specific characters. After all it’s just a keypress to switch and nothing beats US layout for programming. I tried a bit but found that specifying lots of mappings …
Let me propose the following implementation of the described behavior. nnoremap <silent> <leader>zj :call NextClosedFold(‘j’)<cr> nnoremap <silent> <leader>zk :call NextClosedFold(‘k’)<cr> function! NextClosedFold(dir) let cmd = ‘norm!z’..a:dir let view = winsaveview() let [l0, l, open] = [0, view.lnum, 1] while l != l0 && open exe cmd let [l0, l] = [l, line(‘.’)] let open = …
This problem can be solved with the help of the keymap option. It allows to define an alternate keyboard mapping to use in modes requiring text input. To switch between the default and alternate keymaps while in Insert, Replace, or Command-line mode (but not Normal mode), use Ctrl+^ (Ctrl+6). Changing the keymap affects text input …
One way to do that would be: vim “+call cursor(<LINE>, <COLUMN>)” For completeness this is another way: vim “+normal <LINE>G<COLUMN>|”
Could :saveas do the job? :sav[eas][!] [++opt] {file} Save the current buffer under the name {file} and set the filename of the current buffer to {file}. The previous name is used for the alternate file name.