Search for one/many words on commandlinefu, results in vim for easy copy, manipulation. The -R flag is for readonly mode...you can still write to a file, but vim won't prompt for save on quit.
What I'd really like is a way to do this from within vim in a new tab. Something like
:Tex path/to/file
but
:cmdfu search terms
This command searches the current directory, and all of its subdirs, for files that have the string "foo" in their filename (foo.c, two-foo.txt, index-FOO-bar.php, etc), and opens them in Vim. It ignores any hidden .svn directories. Change -iname to -name if you want to do case-sensitive matches. Files open in buffers by default, so to verify that the correct files were opened, type ":list". You can load all the files in tabs by doing ":tab ball" or use 'vim -p' on the command-line to load files straight to tabs. If you get permission denied errors, do: vim $(find . ! -path \*.svn\* -type -f iname \*foo\* 2>/dev/null) To narrow it down to a single file extension, such as .php files, use \*foo\*.php (or '*foo*.php'. Which ever you prefer)
vix /tmp/script.sh
Open a file directly with execution permission.
Put the function in your .bashrc
You can also put this in your vimrc:
command XX w | set ar | silent exe "!chmod +x %" | redraw!
and open a new file like this:
vi +XX /tmp/script.sh
The above output is for a custom compiled version of Vim on Arch Linux. Just a quick shell one liner, and presents a list of all the enabled and disabled (those prefixed with a '-') features. Show Sample Output
Multi-argument version, but with VIM loveliness :D
Use vim's diff mode to edit two or more files in one window. The '+diffoff!' turns off diff highlighting when the session is started. Use ctrl+w + ctrl+w to switch between windows. Show Sample Output
Is this not the same
Opening several files at once in Vim can be very easy in connection with find command.
This command is more for demonstrating piping to vim and jumping to a specific line than anything else. Exit vim with :q! +23 jumps to line 23 - make vim receive the data from the pipe
Often I need to edit a bash or perl script I've written. I know it's in my path but I don't feel like typing the whole path (or I don't remember the path).
: new command allow to split a Vim screen in two separate windows. Each window can handle its own buffer. Passing the -c new options when Vim start cause to split screen automatically.
Because entering ':' requires that you press shift, sometimes common command-line / mini-buffer commands will be capitalized by accident. Show Sample Output
This will save and execute your python script every time your press the F5 function key. It can also be added to your .vimrc: autocmd BufRead *.py nmap :w^M:!python % NOTE: the ^M is not just caret-M, it can be created by type: ctrl-v ctrl-m Show Sample Output
This is one of those 'nothing' shell functions ...which I use all the time.
If the command contains spaces, it must be quoted, e.g.
vimcmd 'svn diff' /tmp/svndiff.out
If I want to keep the output of the command that I'm running, I use vimcmd. If I don't need to keep the output, I use this:
vim <( ... my command ... )
The first argument is the interpreter for your script, the second argument is the name of the script to create. Show Sample Output
Takes the same arguments that ack does. E.g. ack-open -i "searchterm" opens all files below the current directory containing the search term. The search term is also highlighted within vim if you have hlsearch set. Works on zsh, unsure if it works on bash. Note: ubuntu users have to change ack to ack-grep unless you already have it aliased (as I do)
Branch name may be substituted, of course.
If you have some textfile with an unknown encoding you can use this list to find out
Reduce the number of keystrokes it takes to open a file in vim. First of all, you just need to type "v", which is less than half the number of characters (!), and second-of-all, you only need to enter a substring of the file you want to open. For example, if you want to open the file, homework.txt, then type "v hom" to open it. Good tip is to use the lowest unique substring, otherwise you'll open multiple files in different buffers (which is sometimes desirable). Use Ctrl-^ to switch between buffers.
So you keep getting buzzes sounding from pidgin but you can't remember which buddy pounce is causing the beep. Well, cat/edit the ~/.purple/pounces and find out!
By using vim, you can also filter content on stdout, using vim's extra power, like search pattern offset! No more awk of course, sorry. details : -e ex mode -s silent -c 'ex command' : global + start and end pattern + offset print (p) -cq : quit Show Sample Output
A really fun vim oneliner for auto documenting your option's parsing in your script. # print the text embeded in the case that parse options from command line. # the block is matched with the marker 'CommandParse' in comment, until 'esac' extract_cmdl_options() { # use vim for parsing: # 1st grep the case block and copy in register @p + unindent in the buffer of the file itself # 2nd filter lines which start with --opt or +opt and keep comment on hte following lines until an empty line # 3rd discard changes in the buffer and quit vim -n -es -c 'g/# CommandParse/+2,/^\s\+esac/-1 d p | % d | put p | % -c 'g/^\([-+]\+[^)]\+\))/,/^\(\s\+[^- \t#]\|^$\)/-1 p' \ -c 'q!' $0 } example code:http://snipplr.com/view/25059/display-embeded-comments-for-every-opt-usefull-for-auto-documenting-your-script/ Show Sample Output
the second command 'vim !$' will open test.txt to edit Show Sample Output
In this case, we'll be editing every PHP file from the current location down the tree. You can show all the files in the vim buffer with :buffers which outputs something like, :buffers 1 %a "./config/config.php" line 1 2 "./lib/ws-php-library.php" line 0 3 "./lib/css.php" line 0 4 "./lib/mysqldb.class.php" line 0 5 "./lib/config.class.php" line 0 6 "./lib/actions.php" line 0 Press ENTER or type command to continue If you'd like to edit ./lib/mysqldb.class.php for example, enter :b4 anytime you're editing a file. You can switch back and forth. Show Sample Output
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: