New answers tagged

5

You can use feedkeys(): vim +'call feedkeys(":MyCommand")'


3

Try ex +"exe \"normal! ggd/{\<CR>\"" +"normal! Gdd" +"wq" Basically you need to use :execute where you can pass \<CR> inside a double-quoted string UPD as suggested in comments: ex +'exe "normal! ggd/{\<CR>"' +'$d' +wq


0

Assuming the Bash, Ksh or Zsh shell, From inside Vim: :%!sed -e{1,3,4,7}d From the shell itself: sed -e{1,3,4,7}d file Assuming a Sed that supports -i, from the shell itself with in-place editing (i.e., the changes are written to the file rather than only being output): sed -ie{1,3,4,7}d file If the number of lines you want to keep is smaller than the ...


1

If you simply want to delete lines 1, 3, 4, and 7 this should do the trick: :g/\v%1l|%3l|%4l|%7l/d This uses the g command in vim to find all lines that match the given regex. The regex enables very magic at the beginning ofnthe regex with \v making it so that regex branches normally delimited with \| can now be delimited with simply |, as well as various ...


2

No, it is not really possible. Besides the way @Heptite mention, you can do it in 1 command interactively like this: :%s/^import.*\n//c This will ask for confirmation of the line to be deleted. Adjust the search pattern to taste.


3

I came up with this: :for i in reverse([1, 3, 4, 7]) | exe i . 'delete' | endfor This could easily be put into a function that could be called: function DeleteLines(lines) let lines = reverse(uniq(sort(a:lines, 'n'))) for i in lines if i > line('$') echohl WarningMsg echomsg "Warning: Line number " . i . &...


5

In the :help cmdline-completion section, see this paragraph discusses suffixes *c_CTRL-D* CTRL-D List names that match the pattern in front of the cursor. When showing file names, directories are highlighted (see 'highlight' option). Names where 'suffixes' matches are moved to the end. The '...


Top 50 recent answers are included