Hot answers tagged vi
I use both, although if I had to choose one, I know which one I would pick. Still, I'll try to make an objective comparison on a few issues. Available everywhere? If you're a professional system administrator who works with Unix systems, or a power user on embedded devices (routers, smartphones with Busybox, …), you need to know vi (not Vim), because it's ...
I'll post what I think are the main benefits of each: Emacs has considerably more extensions to let you do tasks that are only vaguely text-editor related, like browsing the filesystem or messing with version control, and extensions that are in no way text-editor related, like reading RSS feeds. If you want an environment instead of just a text editor, ...
The command dw will delete from the current cursor position to the beginning of the next word character. The command d$ will delete from the current cursor position to the end of the current line. D is a synonym for d$.
In vi do :1,$d to delete all lines. The : introduces a command (and moves the cursor to the bottom). The 1,$ is an indication of which lines the following command (d) should work on. In this case the range from line one to the last line (indicated by $, so you don't need to know the number of lines in the document). The final d stands for delete the ...
There is a vi available on every unix system (or almost), however you can't say this about any other editor. This is the #1 reason, imo, to learn and familiarize yourself with vi (please note 'vi' not 'vim'). I've never seen Emacs be available in a default install. I'm not saying don't use Emacs or this is the only reason to use Vim, but when you want to be ...
In the page Top Ten One-Liners from CommandLineFu Explained is suggested this trick (the #3): :w !sudo tee % this write the current buffer to the stdin of the command after the !. The % symbol is substituted with the current filename.
In vi I use :%d where : tells vi to go in command mode % means all the line d : delete On the command line, > test.txt will do also. What is the problem with dd? dd if=/dev/null of=test.txt where /dev/null is a special 0 byte file if is input file of is ouput file
Running vi or vim with '-' as an argument makes it read the file to edit from standard input. Hence: grep -e Peugeot -e PeuGeot carlist.txt | vi - will do what you need.
Yes, e.g if you want to do ls, try: :!ls To spawn a shell, use :shell
In normal mode, do 100dd. dd deletes the current line. Prefacing that command with 100 causes it to repeat 100 times.
I'd recommend that you just do this (should work in any POSIX-compliant shell): > test.txt If you really want to do it with vi, you can do: 1G (go to first line) dG (delete to last line)
You can use another character instead of slash / as delimiter to substitution command. Example using #: :%s#/a/b/f/g/d/g#/s/g/w/d/g/r#
You're talking about the greatest feature ever! You can use vi commands to edit shell commands (and command history) by adding this to your .bashrc file: set -o vi You can also run that command from the command line to affect only your current session. If you don't use bash, substitue the appropriate rc file for your shell. This allows you to use vi ...
From man less, v Invokes an editor to edit the current file being viewed. The editor is taken from the environment variable VISUAL if defined, or EDITOR if VISUAL is not defined, or defaults to "vi" if nei‐ ther VISUAL nor EDITOR is defined. See also the discussion of LESSEDIT under the section on PROMPTS below. ...
In insert mode, the cursor is between characters, or before the first or after the last character. In normal mode, the cursor is over a character (newlines are not characters for this purpose). This is somewhat unusual: most editors always put the cursor between characters, and have most commands act on the character after (not, strictly speaking, under) the ...
Pressing dd will remove that line (actually it will cut it). So you can paste it via p.
By setting your readline editing to either emacs (the default) or vi (set -o vi) you are essentially standardizing your editing commands, across the shell and your editor of choice1. Thus, if you want to edit a command in the shell you use the same commands2 that you would if you were in your text editor. This means only having to remember one command ...
Vim tries to resemble the syntax and semantic of Vi command as much as possible. But being an "improved version", Vim adds new commands and features. It also changes the semantic of some Vi commands to better match the current expectations of its programmers. A detailed list of changes between vim and Vi can be found using the command :help compatible in ...
There are many color schemes which are usually distributed together with vim. You can select them with the :color command. You can see the available color schemes in vim's colors folder, for example in my case: $ ls /usr/share/vim/vimNN/colors/ # where vimNN is vim version, e.g. vim74 blue.vim darkblue.vim default.vim delek.vim desert.vim elflord.vim ...
Use the write command: :write Which can be abbreviated: :w If you want to write to another file without changing the current file, supply a different filename to the write command: :write newfile If you want to write to another file and change to that file, use the saveas command: :saveas newfile Which can be abbreviated: :s newfile
I think they're both awesome. I think either one can do just about anything you can imagine, and they're both so customizable, that by the time you finish customizing them, they're both just exactly what you want them to be, nothing more nor less. Emacs stands out to me in being a bit closer (although still does not meet) to ISO/IEC standards of usability ...
The answer turned out to be xp, just not the windows kind ;) If you are working on your vim skills generally you may also find this useful: vi / vim - how to automatically strip trailing spaces on save?
Do this: rm -f ~/.viminfo The .viminfo file keeps metadata about various useful, but non-critical state information. Yours is corrupt. Remove it.
No vi doesn't have any significant advantage over vim rather its the other way around. Vim has more advantages then Vi. You may be interested in : Why, oh WHY, do those #?@! nutheads use vi? Edit also read : Is learning VIM worth the effort?
You should add it to your shell’s configuration file. For Bash, this is ~/.bashrc or ~/.bash_profile. You should also set $VISUAL, as some programs (correctly) use that instead of $EDITOR (see VISUAL vs. EDITOR). Additionally, unless you know why, you should set it to vim instead of vi. TL;DR, add the following to your shell configuration (probably ...
Vim was not designed for large files. It has certain features which drastically slow down the user experience. For instance, it loads the file into memory which basically limits to edit files smaller than your memory size. Furthermore, features such as syntax highlighting, swap file and undo are very inefficient with large files and slow thing down even ...
One of the nice things about vi is its logical command structure. d followed by a motion command deletes to the target of that motion. $ moves to the end of the line (mnemonic: like in regexps). So d$ deletes to the end of the line. Similarly, e moves to the end of the current word, and w moves to the beginning of the next word; so de deletes the end of the ...
I use both on a regular basis. I view Emacs as a "live in" editor, whereas I use Vim for quick, one-off tasks. Superficially, Emacs is much more bloated than Vim is, and so it really isn't quite so convenient to "Fire up" as Vim, but I also find that the philosophies of user interface from one to the other support this paradigm. Emacs is much more built ...
According to the VIM FAQ you can use the :put command: 12.15. How do I insert a blank line above/below the current line without entering insert mode? You can use the ":put" ex command to insert blank lines. For example, try :put ='' :put! ='' For more information, read :help :put but then really it's easier to add: ...
delete 100 lines forward from (including) the current one repeat dd (delete current line) 100 times: 100dd delete from current line to 99 lines forward d99j delete 100 lines backwards from (including) the current one d99k delete lines in a specific range by line number :1,100d delete lines in a range beginning with the current line :.,.+99d ...
Only top voted, non community-wiki answers of a minimum length are eligible