Tag Info

Hot answers tagged


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.


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.


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


At least for vim (not sure about vi), you can do cat file.txt | vim - The '-' tells vim to read from stdin.


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


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


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.


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


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


From command mode, type the upper case letter 'G'.


VI[M] is standard across all systems while the installation for Emacs will vary depending on any number of settings.


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)


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


You have to (either run or) add the following command to your ~/.vimrc file: :syntax on


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


First press ESC so you get back to command mode, then do. :x (quit and save) or :w and :q or :wq


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


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


If you meant vim you can do this with visual-mode (:help visual-mode) and text-objects (:help text-objects). To select a curly-braced block do: v+a+{, to select the enclosing block repeat a+{. Note that you can choose to only select the contents of the braces by using i instead of a. These commands, as many others in vim, are built up by an action followed ...


linespace is only available for the GUI version, i.e. gVim or MacVim, and not console Vim. So maybe you are trying in your terminal? 'linespace' 'lsp' number (default 0, 1 for Win32 GUI) global {not in Vi} {only in the GUI} If you want to modify the linespacing of your ...


I believe the command you're looking for is simply . (period/full stop key). It's a normal mode command, so simply press the key in normal mode.

Only top voted, non community-wiki answers of a minimum length are eligible