vim 7 required
Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) ) This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.
see: https://groups.google.com/forum/?fromgroups=#!topic/vim_use/e3Er8x_P8jg
This oneliner gets all the 'modified' files in your git repository, and opens all of them in vim. Very handy when you're starting to work in the morning and you simply want to review your modified files before committing them. Maybe there are better ways to do that (and maybe integrated in vim and/or git, who knows), but I found quicker to do this oneliner.
A little used command, but one I find very useful when needed. Note: It only works on gitignores in the top level directory.
vim can open ssh/sftp and ftp connections for file editing using 'netrw'. If no path or file is provided vim opens the directory as a filelist. See: :help netrw.
Opens all files in the index (modified plus not added yet) in tabs in vim.
The equivalent of opening each file in vim and doing gg=G:wq . Bufdo makes it faster by obviating the need to start vim for each file separately.
1. easy to type 2. linear list of recursive structure of files/directories 3. search in list using / 4. filter list by :g!//d 5. view/edit file in list by Vgf 6. count files/directories in list by :set nu and G 7. sort by :sort
Instead of using clipboard register after opening vim we can use this command in order to edit clipboard content. For those who already have "xclip -i -selection clipboard -o" aliased to pbpaste it is yet more simple, just: alias vcb='pbpaste | vim -'
this is great if you loose you ssh connection (with out a screen session) or are working on a laptop with a bad battery, or just a power outage. Modifications: you may not need the -print; the mtime is last modified time in days
you should choose proper color to make comments invisible.
Open all files which have some string go directly to the first line where that string is and run command on it.
Other examples:
Run vim only once with multiple files (and just go to string in the first one):
grep -rl string_to_find public_html/css/ | xargs vim +/string_to_find
Run vim for each file, go to string in every one and run command (to delete line):
grep -rl string_to_find public_html/css/ | xargs -I '{}' vim +/string_to_find {} -c ":delete"
simple function i found somewhere to open vim help page from the shell use :h like you would in vim
Open files in tabs
this avoids several VIM warnings, which I seem too stupid to disable: warning, readonly! and: file and buffer have changed, reload?!
The sample command searches for PHP files replacing tabs with spaces.
-u NONE # don't use vimrc
Instead of
retab!
one may pass
retab! 4
for instance.
Look at this http://susepaste.org/69028693 also
I don't know if you've used sqsh before. But it has a handy feature that allows you to switch into vim to complete editing of whatever complicated SQL statement you are trying to run. But I got to thinking -- why doesn't bash have that? Well, it does. It's called '|'! Jk. Seriously, I'm pretty sure this flow of commands will revolutionize how I administer files. And b/c everything is a file on *nx based distros, well, it's handy. First, if your ls is aliased to ls --color=auto, then create another alias in your .bashrc: alias lsp='ls --color=none' Now, let's say you want to rename all files that begin with the prefix 'ras' to files that begin with a 'raster' prefix. You could do it with some bash substitution. But who remembers that? I remember vim macros because I can remember to press 'qa' and how to move around in vim. Plus, it's more incremental. You can check things along the way. That is the secret to development and probably the universe. So type something like: lsp | grep ras Are those all the files you need to move? If not, modify and re-grep. If so, pipe it to vim. lsp | grep ras | vim - Now run your vim macros to modify the first line. Assuming you use 'w' and 'b' to move around, etc., it should work for all lines. Hold down '@@', etc., until your list of files has been modified from ras_a.h ras_a.cpp ras_b.h ras_b.cpp to: mv ras_a.h raster_a.h mv ras_a.cpp raster_a.cpp mv ras_b.h raster_b.h mv ras_b.h raster_b.cpp then run :%!bash then run :q! then be like, whaaaaa? as you realize your workflow got a little more continuous. maybe. YMMV.
Like the http://www.commandlinefu.com/commands/view/6327/open-file-with-sudo-when-there-is-no-write-permission, but works (in zsh; my commandlinefu is not strong enough to understand why bash don't like it) with vim options, like -O, and many input files. There could be other mistakes.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: