Tag Info

Hot answers tagged


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 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


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 ...


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.


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.


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 ...


Pressing dd will remove that line (actually it will cut it). So you can paste it via p.


In normal mode, do 100dd. dd deletes the current line. Prefacing that command with 100 causes it to repeat 100 times.


Yes, e.g if you want to do ls, try: :!ls To spawn a shell, use :shell


Visual Block Mode First, move the cursor to the first char of the first line in block code you want to comment, then type: CTRL + V then vim will go in to VISUAL BLOCK mode. Use j to move the cursor down until you reach the last line of your code block. Then type: Shift + I now vim go to INSERT mode and the cursor is at the first char of the firts ...


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)


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 ...


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 ...


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 ...


As you are using a dark background in your terminal, you simply need to set :set background=dark instead of the default :set background=light The colors are then automatically correctly set. If you want to have this permanently, add the line set background=dark to your $HOME/.vimrc file.


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#


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. ...


vi is (also) a standard. There are plenty of implementations and vim is likely the most popular at least on Linux. While many traditional Unix compliant OSes provide vi implementations very close to the standard, vim has added a lot of extra features that make it a double-edged sword. Of course, these extensions are usually designed to ease the editing ...


Ranges: You can do it with the following command: :66,70s/^/# for comment, and for uncomment: :66,70s/^#/ obviously, here we're commenting lines from 66 to 70 (inclusive). Hope this helps. Regards.


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 ...


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?


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.


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


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