New answers tagged

0 votes

Vim Autoindent does not work

You're correct that smartindent and autoindent should do what you want, but it might be overruled by the archaic compatible setting. Be sure you're not in vi compatible mode. You want set ...
user avatar
0 votes
Accepted

Save all lines of a terminal buffer into a list after its job finishes

The job you get on call-back is a Job object. When used as a string, e.g: echo "Job: " . a:job you get the PID. You can however get a lot of information from the Job spec using various ...
user avatar
  • 360
1 vote

Re-use or close vim terminal buffer on next command run

Re-using is quite easy - name your terminal buffer when starting it, but before you actually start it, check if a term buffer with such name already exists and delete it if yes. For example: function ...
user avatar
0 votes
Accepted

How to keep focus in the "normal" editing buffer while a terminal buffer is opened and running a command?

After the terminal buffer is opened, you can switch back to the previous window with the keys <C-w>p. For non-interactive use (such as in a script), you may append those keystrokes with :normal! ...
user avatar
  • 1,373
1 vote

Controlling Vim from outside

You can also use a JSON channel to send commands to Vim. For more information about this refer to https://vimhelp.org/channel.txt.html#channel-commands. Note that Vim can only be a client and not a ...
user avatar
4 votes

Controlling Vim from outside

For Vim you can use the --remote-send flag. It takes as an argument the Vim command that you would like to be executed. For example: vim --remote-send ":echo 'hello'<CR>" Will echo ...
user avatar
0 votes

vim: FileChangedShell-like notification for file created after editing started

Yeah, as far as I can tell in the vim+neovim source, this would require a patch to add a new feature, it's a separate codepath with no autocommands it would seem: in neovim in vim In both cases this ...
user avatar
1 vote

How to create window split for the current tab?

I believe you want :botright new <filename> or simply :botright new for creating an empty buffer. :bo[tright] {cmd} Execute {cmd}. If it contains a command that splits a window, ...
user avatar
3 votes

How to format code in vim by some external commands?

I would suggest to use :h formatprg and gq normal command. For example, ~/.vim/after/ftplugin/json.vim if executable('jq') let &l:formatprg = "jq -e" elseif executable('js-beautify') ...
user avatar
  • 10.1k
1 vote

How to format code in vim by some external commands?

The gq family of command reformat a section of the code. For some formatter the only option is to format the entire file. I would suggest to use the %! filter pattern that take the entire buffer an ...
user avatar
1 vote

How can I echo a message with newlines so it is displayed with line breaks and is available under :messages

You need to split on newlines and run echomsg multiple times; usually it's easiest to create a little wrapper function for this; for example: fun! s:echo(msg) abort for line in a:msg->split('\n')...
user avatar
0 votes

Backward search in current line with search() and z option

I was looking for a way to jump around "pair" characters in normal and insert mode and stumbled across this question, thanks for this! Basically I was looking for a way to do what the ...
user avatar
1 vote

Can I skip vimscript indentation inside conditional blocks

In the recent vim (I have 8.2.4975) there is a trim parameter and following works for me: if has('python3') py3 << trim PYEND def hello(world): print(world) ...
user avatar
  • 10.1k
0 votes

Can I skip vimscript indentation inside conditional blocks

Is there any problem with stripping off indentation inside the if-block for my "Working use-case"? Indentation is helpful when reading vimscript, but indentation is not required. There is ...
user avatar
2 votes
Accepted

How to delete backwards till whitespace in Insert mode?

Ctrl+o (see :help i_CTRL-O) allows you to perform a single Normal mode command from Insert mode and automatically return to Insert mode after it is executed. As Robert Smith suggested, I would propose ...
0 votes

How to enter terminal buffer using command?

It turns out to be ridiculously hard: Solution 1: no blink on switch terms, can't change bg-color on TermEnter: (simple, so preferred) vim.cmd("au BufEnter,TermOpen term://* if &buflisted | ...
user avatar
  • 751

Top 50 recent answers are included