Hot answers tagged vi
gvim is a GUI version of vim (vi improved). There is also vim available for the Windows command line.
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 !.
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
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.
What about Go, successively? ;-)
At least for vim (not sure about vi), you can do cat file.txt | vim - The '-' tells vim to read from stdin.
Of course. There's Vim - vi improved. It offers a Windows port. Highly recommended.
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 ...
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 ...
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'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.
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 ...
VI[M] is standard across all systems while the installation for Emacs will vary depending on any number of settings.
From command mode, type the upper case letter 'G'.
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
'< 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 ...
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 ...
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.
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)
You have to (either run or) add the following command to your ~/.vimrc file: :syntax on
:%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, ...
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.
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
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 ...
Try: <n>k (You can also use <n>j to move down, <n>h to move left and <n>l to move right) Also: Read :help motion.
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 ...
I do the remapping system-wide via the registry modification outlined at http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows. On the same page, there's also an AutoHotkey solution. You can limit the scope of AutoHotkey remappings like this, which should (untested!) limit to Windows console windows: #IfWinActive ahk_class ConsoleWindowClass ...
Only top voted, non community-wiki answers of a minimum length are eligible