Skip to main content
added 179 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 177
  • 165

Running in a pipeline

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to use an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Even though the output of quickedit is redirected to a pipeline, vim still works normally because we have given it direct access to /dev/tty.

Running a program from within vim

As I mentioned in the comments, vim can pipe a file to a command. From within vim, for example, issue the command :w !pandoc -o file.pdf (Note: the space between w and ! is essential).

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to use an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Even though the output of quickedit is redirected to a pipeline, vim still works normally because we have given it direct access to /dev/tty.

Running in a pipeline

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to use an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Even though the output of quickedit is redirected to a pipeline, vim still works normally because we have given it direct access to /dev/tty.

Running a program from within vim

As I mentioned in the comments, vim can pipe a file to a command. From within vim, for example, issue the command :w !pandoc -o file.pdf (Note: the space between w and ! is essential).

added 151 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 177
  • 165

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to use an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Even though the output of quickedit is redirected to a pipeline, vim still works normally because we have given it direct access to /dev/tty.

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to use an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to use an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Even though the output of quickedit is redirected to a pipeline, vim still works normally because we have given it direct access to /dev/tty.

deleted 8 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 177
  • 165

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect > /dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to make selectuse an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect > /dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to make select an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 

Try:

quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) 

The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty.

For purposes of security, I put the temporary file in the user's home directory. For more on this, see Greg's FAQ Question 062. This eliminates the need to use an obscure file name.

Example:

When vim opens, I type This function succeeded. and save the file. The result on the screen looks like:

$ quickedit | grep succeeded This function succeeded. 
added 329 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 177
  • 165
Loading
added 329 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 177
  • 165
Loading
Source Link
John1024
  • 76.4k
  • 12
  • 177
  • 165
Loading