Colored diff ( via vim ) on 2 remotes files on your local computer.
$ vimdiff scp://root@server-foo.com//etc/snmp/snmpd.conf scp://root@server-bar.com//etc/snmp/snmpd.conf You can use vim scp://root@example.com//file too in a simple case. View this command to comment,...
View ArticlePipe STDOUT to vim
$ tail -1000 /some/file | vim - The hyphen tells vim to open from STDOUT - saves having to create temporary files. View this command to comment, vote or add to favourites View all commands by root Diff...
View ArticleVI config to save files with +x when a shebang is found on line 1
$ au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent !chmod +x <afile> | endif | endif Add this to .vimrc to automatically give scripts with a shebang (e.g.,...
View ArticleDelete all empty lines from a file with vim
$ :g/^$/d View this command to comment, vote or add to favourites View all commands by acumon Diff your entire server config at ScriptRock.com
View ArticleMakes you look busy
$ alias busy='my_file=$(find /usr/include -type f | sort -R | head -n 1); my_len=$(wc -l $my_file | awk "{print $1}"); let "r = $RANDOM % $my_len" 2>/dev/null; vim +$r $my_file' This makes an alias...
View Articleuse vim to get colorful diff output
$ svn diff | view - :q to quit View this command to comment, vote or add to favourites View all commands by freestyler Diff your entire server config at ScriptRock.com
View ArticleOpens vi/vim at pattern in file
$ vi +/pattern [file] Open up vi or vim at the first instance of a pattern in [file]. Useful if you know where you want to be, like "PermitRootLogin" in sshd_config. Also, vi +10 [file] will open up a...
View ArticleSave your sessions in vim to resume later
$ :mksession! <filename> Creates a full snapshot of your current vim session, including tabs, open buffers, cursor positions, everything. Can be resumed with vim -S . Useful for those times when...
View ArticleSave a file you edited in vim without the needed permissions (no echo)
$ :w !sudo tee > /dev/null % Write a file you edited in Vim but that you do not have the permissions to write to (unless you use sudo.) Same as #1204 but without the echo to stdout that I find...
View ArticleBring the word under the cursor on the :ex line in Vim
$ :<C-R><C-W> Very handy to bring the word currently under the cursor into a :s command in Vim. Example: If the cursor was on the word "eggs": :s/ ==> :s/eggs View this command to...
View ArticleAdd Password Protection to a file your editing in vim.
$ vim -x <FILENAME> While I love gpg and truecrypt there's some times when you just want to edit a file and not worry about keys or having to deal needing extra software on hand. Thus, you can...
View Article