New answers tagged

0

Try defining in your vimrc: :command! Include call Ins()<CR> And define your function in your vimrc(it is referenced in the comments). Then use :Include to execute.


0

I think what you want is an abbreviation when you are in insert mode. Try adding the following to your .vim/ftplugin/cpp.vim file: iabbr <buffer> include() /home/yapjiahong/projects/cpp/add-libraries/plog/include Now, whenever you are in insert mode and type include() followed by a space or return, the text on the right hand side will automatically ...


1

Suppose Vim is running, you can use Vim remote to send commands. I suggest to keep it running (i.e. bg after ctrl z) and then use vim --remote to send an edit command to it. If you don't want to do this, a possible solution is to use a file that will contain a file list. Vim will check it when running and load buffers from this file. Use au GuiEnter maybe.


3

To follow up on @Christian Brabandt's answer, you can use the O key (see :help O) and do: :g/^Q/norm O norm allows to run a key command (O, dd, .....) in a command. :g can take a range also, so if you don't want to do it on the first question, you could do: `:2,$g/^Q/norm O Assuming that your file contains only that text, otherwise, the range needs to be ...


3

You can make use of the :g command. There are probably already answers here on how to use :g and there is also this famous wiki article on the same topic In short, you simply run: :g/^Q/:-put ='' which basically means, for each line starting with Q put an empty line above it. Alternatively you could use: :g/^b/:pu ='' which would add an empty line below ...


2

This seems to work: au CmdLineEnter * set norelativenumber | redraw au CmdlineLeave * set relativenumber Edit: apparently the window does not redraw while you are in the command mode, so you need to force the redraw explicitly to get the effect of the command to be shown. And apparently you also do not need | redraw for CmdlineLeave case, because when you ...


1

It's somewhat easy to get a function definition and open it in Vim for editing: declare -f e l vim - But there are many shortcomings with that approach. For instance, exiting Vim after editing the file won't really reload the function with the new definition. In fact, the buffer you get by reading it from standard input is an unnamed buffer, so Vim won't ...


3

You want the :redir family of commands. See :h :redir. For example... :redir > /path/to/file Then run :au. Then :redir END And the file will contain the same things you saw on the screen. This should work for any command that emits "messages" (echoes to the screen). You can also append. And you can redirect to registers and variables. Again, ...


Top 50 recent answers are included