Skip to content

Instantly share code, notes, and snippets.

@Johnytran
Johnytran / vim
Created June 12, 2016 03:31
copy to cliboard
"+y
@Johnytran
Johnytran / vim
Created June 12, 2016 02:28
text selection
text selection
If you want to do the same thing to a collection of lines, like cut, copy, sort, or format, you first need to select the text. Get out of insert mode, hit one of the options below, and then move up or down a few lines. You should see the selected text highlighted.
V - selects entire lines
v - selects range of text
ctrl-v - selects columns
gv - reselect block
@Johnytran
Johnytran / vim
Created June 12, 2016 01:10
indent a block
shift v to select block
Press > to indent (shift text one 'shiftwidth' to the right), or press < to shift left.
@Johnytran
Johnytran / nerdtree
Created June 11, 2016 05:03
Nerdtree move
Crtl+ww cycle though all windows
Crtl+wh takes you left a window
Crtl+wj takes you down a window
Crtl+wk takes you up a window
Crtl+wl takes you right a window
@Johnytran
Johnytran / vim
Last active June 16, 2016 01:01
copy cut paste
To cut-and-paste or copy-and-paste:
Position the cursor at the beginning of the text you want to cut/copy.
Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block.
Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement.
Press d (delete) to cut, or y (yank) to copy.
Move the cursor to the desired paste location.
Press p to paste after the cursor, or P to paste before.
above for buffer inside vim
@Johnytran
Johnytran / vim
Created March 14, 2016 08:09
Status bar for vim
https://github.com/powerline/powerline
@Johnytran
Johnytran / vim
Created March 9, 2016 09:07
duplicate line in vim
:t. will duplicate the line,
:t 7 will copy it after line 7,
:,+t0 will copy current and next line at the beginning of the file (,+ is a synonym for the range .,.+1),
:1,t$ will copy lines from beginning till cursor position to the end (1, is a synonym for the range 1,.).
If you need to move instead of copying, use :m instead of :t.
This can be really powerful if you combine it with :g or :v:
:v/foo/m$ will move all lines not matching the pattern “foo” to the end of the file.
:+,$g/^\s*class\s\+\i\+/t. will copy all subsequent lines of the form class xxx right after the cursor.
@Johnytran
Johnytran / vim
Created October 10, 2015 05:09
vim search content in files
http://www.vim.org/scripts/script.php?script_id=311
@Johnytran
Johnytran / vim
Created September 26, 2015 05:45
html xml auto close tags for vim
https://github.com/othree/xml.vim
@Johnytran
Johnytran / vim
Created September 26, 2015 04:53
Select all text in vim
The simplest and fastest way is to use: : % y + and then go over to Google Docs (or wherever) and paste.
Another way is g g " + y G but you will likely admitt that the above is faster and easier.