Quantcast
Channel: Commands using vi
Browsing all 21 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

find all files containing a pattern, open them using vi and place cursor to...

$ find . -type f -exec grep -l pattern {} \; | xargs vi +/pattern View this command to comment, vote or add to favourites View all commands by unixmonkey982 by David Winterbottom (codeinthehole.com)

View Article



Image may be NSFW.
Clik here to view.

Edit a file using vi or vim in read-only mode

$ vi -R filename The -R flag prevents you from making changes to a file, useful when you only want to view the file. This command is nicer than the 'more' or 'less' commands because for source codes,...

View Article

Image may be NSFW.
Clik here to view.

Search for the file and open in vi editor.

$ vifind() { vi `find . -name "$1"` } View this command to comment, vote or add to favourites View all commands by deepanaidu by David Winterbottom (codeinthehole.com)

View Article

Image may be NSFW.
Clik here to view.

Update your journal

$ vi ~/journal/$(date +%F) prerequisite: mkdir ~/journal View this command to comment, vote or add to favourites View all commands by ar by David Winterbottom (codeinthehole.com)

View Article

Image may be NSFW.
Clik here to view.

automount samba shares as devices in /mnt/

$ sudo vi /etc/fstab; Go//smb-share/gino /mnt/place smbfs defaults,username=gino,password=pass 0 0<esc>:wq; mount //smb-share/gino the middle command between the ; and ; is the vi commands that...

View Article


Image may be NSFW.
Clik here to view.

Edit file(s) that has been just listed

$ vi `!!` That will open vi with the four README files in different viewports. Specially handy when you find there is only one file matching your pattern and you don't want to specify the full path....

View Article

Image may be NSFW.
Clik here to view.

edit list of files in last command

$ vi `!!` say you've just found all the config files with this command find . -name '*.config' and you need to edit them all vi `!!` will re-execute the command and present them to vi in the argument...

View Article

Image may be NSFW.
Clik here to view.

Edit Crontab

$ vi ~/.crontab && crontab ~/.crontab this lets you edit a crontab file (which may be used as a backup as well) and insert this into your crontab. this way is especially handy, when multiple...

View Article


Image may be NSFW.
Clik here to view.

Opens 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 Article


Image may be NSFW.
Clik here to view.

function to edit your history file

$ eh () { history -a ; vi ~/.bash_history ; history -r ; } eh stands for Edit History . Frequently, I'll mistype a command, and then step back through my history and correct the command. As a result,...

View Article

Image may be NSFW.
Clik here to view.

Setup Vim environment for USACO coding

$ alias viaco='task="$(basename "$(pwd)")"; if [ -f "$task.c" ]; then vi -c "set mouse=n" -c "set autoread" -c "vsplit $task.out" -c "split $task.in" -c "wincmd l" -c "wincmd H" $task.c; fi' 1. Get...

View Article

Image may be NSFW.
Clik here to view.

Go to the Nth line of file [text editor]

$ vi +4 /etc/mtab This is not printing, real editing using the text editor. View this command to comment, vote or add to favourites View all commands by totti by David Winterbottom (codeinthehole.com)

View Article

Image may be NSFW.
Clik here to view.

Remove a line from a file using sed (useful for updating known SSH server...

$ vi +<lineNumber>d +wq <filename> For example, to remove line 5 from foo, type: vi +5d +wq foo View this command to comment, vote or add to favourites View all commands by detert by David...

View Article


Image may be NSFW.
Clik here to view.

Remove a range of lines from a file

$ vi +{<end>..<start>}d +wq <filename> Deletes lines to of a file. You must put the end line first in the range for the curly brace expansion, otherwise it will not work properly....

View Article

Image may be NSFW.
Clik here to view.

Remove a range of lines from a file

$ vi +START,ENDd +wq sample.txt Deletes lines from START to END, inclusive. For example +4,10d will delete line 4, 5, ..., 10. Just like the vi command :4,10d does it. View this command to comment,...

View Article


Image may be NSFW.
Clik here to view.

Remove a range of lines from a file

$ vi +'<start>,<end>d' +wq <filename> View this command to comment, vote or add to favourites View all commands by daa by David Winterbottom (codeinthehole.com)

View Article

Image may be NSFW.
Clik here to view.

vi a remote file

$ vi scp://username@host//path/to/somefile notice the double slash View this command to comment, vote or add to favourites View all commands by huazhihao by David Winterbottom (codeinthehole.com)

View Article


Image may be NSFW.
Clik here to view.

vi a remote file with port

$ vi scp://username@host:12345//path/to/somefile If you are running sshd on different port use above this command to edit/view remote file with vi/vim. In above example I am using port 12345. View this...

View Article

Image may be NSFW.
Clik here to view.

Easy IPTables management

$ iptables-save > iptables.current; vi iptables.current; iptables-restore iptables.current; service iptables save These series of commands allows you all at once to make a backup of your current...

View Article

Image may be NSFW.
Clik here to view.

allows you to view your .bash_history file

$ $ vi .bash_history brings up all your history for modification or get rid of the history on linux files View this command to comment, vote or add to favourites View all commands by shoustonbound by...

View Article
Browsing all 21 articles
Browse latest View live




Latest Images