Hot answers tagged vi
The simplest and fastest way is to use: : % y + and then go over to Google Docs (or wherever) and paste. Another way is g g " + y G but you will likely admitt that the above is faster and easier.
From SO: :w !sudo tee % I actually find myself using this way to do it more frequently now: :%!sudo tee % I think it's a little more intuitive, as I know what :%! does, whereas I don't have a visceral understanding of :w !. Also, it's easy to miss the very important space between the w and the !.
gvim is a GUI version of vim (vi improved). There is also vim available for the Windows command line.
First, make sure you have the proper Vim packages installed. The default on many systems is to install a minimal Vim package that is closer to Vi in functionality. On Red Hat based systems (RHEL, CentOS, Fedora), you need the vim-enhanced package, for example from a CentOS system I have installed: vim-common-7.0.109-4.el5_2.4z ...
In your .bashrc: alias vi=vim
What about Go, successively? ;-)
You can use cat file and then select output and copy and paste if you need to paste it into your browser. For vi this is how you can select all text and write it into a new file: shift v -- visual mode shift g -- jump to eof "*y -- yank select text :e my_new_file -- create a new file "*p -- paste into a new file In theory this should work on both Linux ...
At least for vim (not sure about vi), you can do cat file.txt | vim - The '-' tells vim to read from stdin.
This should do the trick: vim $(find . -name "*.txt") Use VIM, it's better for your health. :-) Piping into xargs vi gives a Warning: Input is not from a terminal, plus a terminal with completely bogus behaviour afterwards. User grawity explained why in a comment below, and with a bit more explanation in this question.
I use vim_mode.pl with irssi (in GNU screen) and am extremely satisfied with the combination. For anyone who doesn't know Irssi, it's terminal-based and there is no GUI available or planned. While this may put some people off, it makes for a great combination with GNU screen, and allows you to keep your connection while being logged out: Always a good ...
Note: Due to legacy licensing reasons, most GNU/Linux distributions don’t include the original vi program as written by Bill Joy. Instead, the vi command is provided by running Vim in vi-compatibility mode. The following answer is based on running Vim with its vi-compatibility mode. Modifying a read-only file Vim warns the user if they modify the buffer of ...
I've been using these map <Enter> o<ESC> map <S-Enter> O<ESC> in my .vimrc for years. Press Enter to insert a blank line below current, Shift + Enter to insert it above.
Of course. There's Vim - vi improved. It offers a Windows port. Highly recommended.
Note: You should look at man zshzle for a lot of goodies about customizing bindkey and emulating GNU readline. This is how I mapped jj to Esc: bindkey -M viins 'jj' vi-cmd-mode If you're interested in distinguishing between insert-mode and normal-mode, you could try out the suggestion akira mentions here
You have to (either run or) add the following command to your ~/.vimrc file: :syntax on
From command mode, type the upper case letter 'G'.
The pasted message suggests you still have the "notes" file open in another Vim session. It is definitely not a good idea to edit a file that is being edited elsewhere. If that message is wrong, you need to determine how your Vim session exited improperly and avoid that in the future. As for recovering, that may be an issue in this one instance since ...
VI[M] is standard across all systems while the installation for Emacs will vary depending on any number of settings.
Yes, you can do it with :%s//bar. Explanation: in the substitute command when the search pattern is empty, Vim uses the last search pattern. Alternatively, you can explicitly paste the last search pattern, which is stored in a special register. You can quickly insert its contents by typing Ctrl-R+/ in insert or command mode. So enter command mode, type ...
In this case, I write the file with :w /tmp/tmpfile. Then I go out and move /tmp/tmpfile to my old file with sudo rights.
This message is actually pretty important if you care about not losing text you've potentially not saved. It should not be considered annoying, and should not cause you to hastily delete the swap file or configure vim to run without it. Any file you edit with vim will have a corresponding swap file while you edit, which vim uses to keep track of changes. ...
RedHat based systems have a package called vim-minimal installed by default, which has a limited set of features enabled. You want to install the vim-enhanced package. Debian based systems do something similar, where vim-tiny is the default install and has a minimal feature set. Your Ubuntu system must have one of the other Vim packages installed (likely ...
If it is a Debian or Ubuntu system, and you want to make this change system wide, you should use update-alternatives (specify with the --config editor options, and you should be golden)
'< and '> are marks corresponding to the beginning and end of a visual selection. Separated by a , they form a range that is inserted automatically for you when you hit : while in visual mode. That way, you can execute an Ex command (like s or d) against the selected lines without having to type the range yourself. Handy! And the best part is that ...
I later found that I had installed both vi and vim on Cygwin, so I added this to my .bashrc: alias vi="/usr/bin/vim" and then created the following ~/.vimrc file: " double-quotes are comments for the .vimrc file set nocompatible set nocp set backspace=indent,eol,start set term=xterm-256 syntax on set hlsearch set t_Co=8 set t_Sb=m set t_Sf=m I now have ...
Well it actually seems like you can build vim without support for visual mode. Check the output of :ver and see whether it says +visual or -visual. Bad luck if it's the latter.
you might try this: % vi `cat file.txt` or, to avoid the useles use of cat: % vi `< file.txt` you are telling vi(m) just a bunch of arbitrary things. if you want vi(m) to do something like 'hey, open that file' you have to feed it the same commands you would use in vi(m), eg. something like :e foo.txt. but thats just more complicated than doing what ...
Another option is to select the lines using Shift+V as Ignacio suggests, but then press > (greater than sign). That does an indent according to your indentation settings (shiftwidth, expandtab, etc). You can also indent more than one level with number>, e.g. 2> to indent two levels. Finally, if Vim recognizes the file type (type :set filetype?, it should ...
First press ESC so you get back to command mode, then do. :x (quit and save) or :w and :q or :wq
:%s/x/y/g This command replaces all instances of x in the current file with y. This is basically just a find and replace, but I use it so often since I've learned it at work that it has become invaluable. Also, /search string then n to navigate through all instances of the search string within the file. Great for doing manual tweaks a lot more easily, ...
Only top voted, non community-wiki answers of a minimum length are eligible