Why doesn't history | vim work?
By piping into vim, you are changing the standard input stream. Because vim is an interactive program, it requires the standard input to be the console.
If you want to view in vim, you should tell it you are reading the file from stdin (by supplying the argument -
):
history | vim -
Alternatively, you could just use more or less:
history | more
history | less
These latter two are preferable. If you pipe into vim, it will see your "file" as having modifications, and so you can't quit with a straight :q
command. Instead you have to force quit by :q!
, which is a bit clunky.
On the other hand, you can exit more or less just by typing q
. Have a look at the man-page for these two programs. You'll use them a lot.
As recommended by Russell Silva in the comments, you can open vim in read-only mode when you read from stdin. Just supply the -R
argument. Then you can quit normally without needing the override:
history | vim -R -
vim syntax doesn't work at all
vim
tries to automatically determine the file type. If it detects a known type, it will use syntax highlighting. If it doesn't detect the type, it does not know which syntax to use (e.g. Java/vimrc/apache-config).
You can always check which file type vim
thinks the current document has by using the command :set filetype
. If the variable is empty, vim
does now know which type of file this is and thus cannot use syntax highlighting.
There are several possibilities to "help" vim
determine the file type.
- The easiest is to use the correct file extension: If, for example, you open a file called
test.html
,vim
knows that you will probably fill this file with HTML code and thus automatically sets thefiletype
variable tohtml
. - You can also just write the file in a manner so that
vim
knows what kind of file this is. If, for example, a file begins with#!/bin/bash
,vim
knows that this is abash
script and sets thefiletype
variable tobash
. - If all else fails, you can also tell
vim
thefiletype
explicitly. Either set it in the editor, e.g.:set filetype=bash
, or use a modeline, e.g.# vim:filetype=bash
.
Regardless of whether the file type was correctly identified, vim
needs to know which colours to use for which words. These are specified in "vim syntax files". On Debian, these are located in /usr/share/vim/vim<your-vim-version>/syntax
, e.g. /usr/share/vim/vim74/syntax
. I don't know if the location is the same on Kali, but I suspect it will be similar. If there is no vim syntax file for the file type you are editing, vim
cannot help you. However, you might be able to find a syntax file online or in another package.
Vim – document navigation don't work on cyryllic texts in Windows but works in Linux
After creating issue on Github (https://github.com/vim/vim/issues/8588) I got a respond from habamax about the problem. It seems that in old versions of Windows vim utf-8 is not used by default. Editing vimrc or using nightly build (as habamax suggested in the issue) solves the problem.
Vim set noundofile doesn't work, Vim still creates undo files
You have no business editing anything in Vim's installation directory. Whatever you do to configure Vim must happen in your own runtime directory, located in your own "home directory", and nowhere else:
%USERPROFILE%\vimfiles
If it doesn't already exist, create it yourself.
Disabling undo files is indeed done with
set noundofile
, that you are supposed to put in your ownvimrc
, under the directory mentioned above:%USERPROFILE%\vimfiles\vimrc
That file is sourced after any system-level
vimrc
so whatever you put in that file will take precedence. It is yourvimrc
.
Related Topics
Pytorch Says That Cuda Is Not Available
How to Compile Glibc 32Bit on an X86_64 MAChine
Hadoop: Require Root's Password After Enter "Start-All.Sh"
Why Doesn't "History | Vim" Work
Nginx: [Emerg] Unknown Directive " " in /Etc/Nginx/Sites-Enabled/Example.Com:3
How to Reset Emacs to Save Files in Utf-8-Unix Character Encoding
Populate a Ms Access Database in Linux
Use Sed with Ignore Case While Adding Text Before Some Pattern
Replace String in a File with Value from Another File
Linux Command to Delete All Files Except .Git Folder
Docker Behind Proxy That Changes Ssl Certificate
How to Load Jna Native Support Library Elasticsearch 6.X
Why Mongodb Performance Better on Linux Than on Windows