Increment next number in vim
$ CTRL + A ( in normal mode ) View this command to comment, vote or add to favourites View all commands by Zulu Diff your entire server config at ScriptRock.com
View ArticleRun bash on top of a vi session (saved or not saved), run multiple commands,...
$ :shell View this command to comment, vote or add to favourites View all commands by unixmonkey41067 Diff your entire server config at ScriptRock.com
View ArticleOpen all files with a regular expression in vim
$ vim $(grep [REGULAR_EXPRESSION] -R * | cut -d":" -f1 | uniq) View this command to comment, vote or add to favourites View all commands by eduardostalinho Diff your entire server config at...
View ArticleOpen (in vim) all modified files in a git repository
$ vim `git status | grep modified | awk '{print $3}'` 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...
View ArticleOpen (in vim) all modified files in a git repository
$ vim `git status --porcelain | sed -ne 's/^ M //p'` The option --porcelain makes the output of git easier to parse. This one-liner may not work if there is a space in the modified file name. View this...
View ArticleGrep inside Vim and navigate results
$ :vimgrep pattern % Will search for the given pattern and build a list of occurrences. Then you can use :copen and :cclose to toggle the list. When browsing the list, ENTER will take you to that line...
View ArticlePaste what you previously wrote in INSERT MODE
$ . (in NORMAL MODE) Paste what you previously wrote in INSERT MODE, for example: 1. Write 'foo' in INSERT MODE 2. Return to NORMAL MODE 3. Press "." and it will paste 'foo' View this command to...
View Articleedit hex mode in vim
$ :%!xxd return to normal mode from hex mode :%!xxd -r View this command to comment, vote or add to favourites View all commands by b1067606 Diff your entire server config at ScriptRock.com
View Articlevim multiple files at one time, split vertically.
$ vim -O file1 file2 View this command to comment, vote or add to favourites View all commands by kyle Diff your entire server config at ScriptRock.com
View Articlevi a remote file with port
$ vim sftp://[user@]host.domain.tld:[port]/[path/][file] 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....
View ArticleOpen (in vim) all modified files in a git repository
$ vim -p `git --porcelain | awk {print $2}` Opens all files in the index (modified plus not added yet) in tabs in vim. View this command to comment, vote or add to favourites View all commands by...
View ArticleGo to a specified line in a file
$ vim +143 filename.txt View this command to comment, vote or add to favourites View all commands by techie Diff your entire server config at ScriptRock.com
View ArticleOpen a file using vim in read only (like less)
$ vim -R /etc/passwd View this command to comment, vote or add to favourites View all commands by techie Diff your entire server config at ScriptRock.com
View ArticleOpen a file using vim in read only (like less)
$ view /file/name View this command to comment, vote or add to favourites View all commands by mc0e Diff your entire server config at ScriptRock.com
View ArticleLoad your [git-controlled] working files into the vi arglist.
$ vim $(git diff origin/master --name-only) Branch name may be substituted, of course. View this command to comment, vote or add to favourites View all commands by sodapopcan Diff your entire server...
View ArticleDelete all empty lines from a file with vim
$ ggqqqqq/^$dd@qq@q Here's the other way of doing it in vim: setting a recursive macro. 'gg' brings you to the top of the buffer, 'qqq' clears the 'q' macro, 'qq' starts recording a macro called 'q',...
View ArticleDelete all empty lines from a file with vim
$ :v/./d If you need to delete lines that may contain space characters (such as tabs or spaces) as well as empty ones, try: :v/\S/d Just an alternative. View this command to comment, vote or add to...
View ArticleInclude a remote file (in vim)
$ :r scp://yourhost//your/file Like vim scp://yourhost//your/file but in vim cmds. View this command to comment, vote or add to favourites View all commands by Zulu Diff your entire server config at...
View Articlevim - save document with privileges from vim
$ :w !sudo tee % View this command to comment, vote or add to favourites View all commands by KodjoSuprem Diff your entire server config at ScriptRock.com
View Articlevi show line numbers
$ :set number Prints line numbers making it easier to see long lines that wrap in your terminal and extra line breaks at the end of a file. :set nu works too. View this command to comment, vote or add...
View Article