Home Explore Blog CI



neovim

14th chunk of `runtime/doc/quickfix.txt`
40a5f30dc6a58bf41289faebd7c5cf023fd8a2901923d64d0000000100000fa0
 'makeencoding'
			option to specify the encoding.

							*:lmak* *:lmake*
:lmak[e][!] [arguments]
			Same as ":make", except the location list for the
			current window is used instead of the quickfix list.

The ":make" command executes the command given with the 'makeprg' option.
This is done by passing the command to the shell given with the 'shell'
option.  This works almost like typing

	":!{makeprg} [arguments] {shellpipe} {errorfile}".

{makeprg} is the string given with the 'makeprg' option.  Any command can be
used, not just "make".  Characters '%' and '#' are expanded as usual on a
command-line.  You can use "%<" to insert the current file name without
extension, or "#<" to insert the alternate file name without extension, for
example: >
   :set makeprg=make\ #<.o

[arguments] is anything that is typed after ":make".
{shellpipe} is the 'shellpipe' option.
{errorfile} is the 'makeef' option, with ## replaced to make it unique.

The placeholder "$*" can be used for the argument list in {makeprg} if the
command needs some additional characters after its arguments.  The $* is
replaced then by all arguments.  Example: >
   :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
or simpler >
   :let &mp = 'latex \\nonstopmode \\input\{$*}'
"$*" can be given multiple times, for example: >
   :set makeprg=gcc\ -o\ $*\ $*

The 'shellpipe' option defaults to "2>&1| tee" for Win32.
This means that the output of the compiler is saved in a file and not shown on
the screen directly.  For Unix "| tee" is used.  The compiler output is shown
on the screen and saved in a file the same time.  Depending on the shell used
"|& tee" or "2>&1| tee" is the default, so stderr output will be included.

If 'shellpipe' is empty, the {errorfile} part will be omitted.  This is useful
for compilers that write to an errorfile themselves.


Using QuickFixCmdPost to fix the encoding ~

It may be that 'encoding' is set to an encoding that differs from the messages
your build program produces.  This example shows how to fix this after Vim has
read the error messages: >

	function QfMakeConv()
	   let qflist = getqflist()
	   for i in qflist
	      let i.text = iconv(i.text, "cp936", "utf-8")
	   endfor
	   call setqflist(qflist)
	endfunction

	au QuickfixCmdPost make call QfMakeConv()

(Example by Faque Cheng)
Another option is using 'makeencoding'.

==============================================================================
5. Using :vimgrep and :grep				*grep* *lid*

Vim has two ways to find matches for a pattern: internal and external.  The
advantage of the internal grep is that it works on all systems and uses the
powerful Vim search patterns.  An external grep program can be used when the
Vim grep does not do what you want.

The internal method will be slower, because files are read into memory.  The
advantages are:
- Line separators and encoding are automatically recognized, as if a file is
  being edited.
- Uses Vim search patterns.  Multi-line patterns can be used.
- When plugins are enabled: compressed and remote files can be searched.
	|gzip| |netrw|

To be able to do this Vim loads each file as if it is being edited.  When
there is no match in the file the associated buffer is wiped out again.  The
'hidden' option is ignored here to avoid running out of memory or file
descriptors when searching many files.  However, when the |:hide| command
modifier is used the buffers are kept loaded.  This makes following searches
in the same files a lot faster.

Note that |:copen| (or |:lopen| for |:lgrep|) may be used to open a buffer
containing the search results in linked form.  The |:silent| command may be
used to suppress the default full screen grep output.  The ":grep!" form of
the |:grep| command doesn't jump to the first match automatically.  These
commands can be combined to create a NewGrep command: >

        command! -nargs=+ NewGrep execute 'silent grep! <args>' | copen 42


5.1 Using Vim's internal grep

					*:vim* *:vimgrep* *E682* *E683*

Title: Advanced :make Usage, Encoding Considerations, and Internal vs External Grep
Summary
This section expands on the :make command, explaining how to use placeholders like $* for arguments in 'makeprg'. It also covers 'shellpipe' and its defaults on different systems. It includes an example function QfMakeConv() to adjust encoding using QuickfixCmdPost. Furthermore, it discusses the differences between Vim's internal and external grep commands, highlighting internal grep's advantages in recognizing line separators, encoding, and using Vim search patterns, including multi-line patterns, as well as its support for compressed and remote files. It shows the combination of :silent, :grep!, and :copen to create a NewGrep command.