{"id":6063,"date":"2014-03-09T11:07:04","date_gmt":"2014-03-09T15:07:04","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=6063"},"modified":"2014-03-09T11:07:04","modified_gmt":"2014-03-09T15:07:04","slug":"6063","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/6063\/","title":{"rendered":"Mastering Vim in Vim"},"content":{"rendered":"<p>From <a href=\"http:\/\/nerds.weddingpartyapp.com\/tech\/2013\/11\/17\/mastering-vim-in-vim\/\" target=\"_blank\" rel=\"noopener noreferrer\">nerds.weddingpartyapp.com<\/a><\/p>\n<header>\n<h2 class=\"entry-title\"><\/h2>\n<h2 class=\"entry-title\">Mastering Vim in Vim<\/h2>\n<\/header>\n<p><img decoding=\"async\" alt=\"Learning Curves\" src=\"http:\/\/nerds.weddingpartyapp.com\/images\/posts\/learning_curves.jpg\" \/><\/p>\n<p>Vim has a deserved reputation for being difficult to learn. The included <code>vimtutor<\/code> program will teach you the absolute basics, enough to allow you to edit a file, but what if you want to achieve the extreme proficiency you\u2019ve heard vim users are capable of?<br \/>\n<!--more--><br \/>\nThere are many good articles about learning vim a quick google search away, and <a href=\"http:\/\/vimcasts.org\/\">vimcasts<\/a> has some great screencasts, but those resources are not explicitly geared towards helping you achieve mastery through practice. You might learn some interesting tricks, but how do you ensure you will be able to remember them long enough to use them? What you need is a vim study lab!<\/p>\n<p>A vim study lab consists of a large set of the textual equivalent of study cards with some vim commands to make navigating the cards easier. As an added bonus, since the lab is within vim, you can try out any commands on the cards easily.<\/p>\n<p>Here\u2019s an example of a <a href=\"https:\/\/gist.github.com\/gmccreight\/7519289\/raw\/master.vim\">vim-study-lab-in-a-file<\/a>. The file, when sourced, turns the vim buffer into the vim study lab. The file consists of two parts. The first part is a hunk of vimscript that is executed when you source the file. It creates keyboard commands that make it easy to move the cards in the queues.<\/p>\n<p>The second part is the queues themselves, Study, and Known. (The idea is that once you know something <em>so well<\/em> that you don\u2019t need to study it anymore, you can move it into the Known queue, just to keep it around for posterity.) The queues simply consist of a command and some information about it.<\/p>\n<p><code><br \/>\n\" copy all this into a vim buffer, save it, then...<br \/>\n\" source the file by typing :so %<br \/>\n\" Now the vim buffer acts like a specialized application for mastering vim<\/p>\n<p>\" There are two queues, Study and Known.  Depending how confident you feel<br \/>\n\" about the item you are currently learning, you can move it down several<br \/>\n\" positions, all the way to the end of the Study queue, or to the Known<br \/>\n\" queue.<\/p>\n<p>\" type ,, (that's comma comma)<br \/>\n\" You know the command pretty well, but not enough to move it to 'Known'.<br \/>\n\" ,, moves the current command to the bottom of the 'Study' queue.<br \/>\nnmap ,, ^v\/^$<cr>dma\/^= Known<\/cr><cr>P'azt<c -y><\/c><c -l><\/p>\n<p>\" type ,c (that's comma c)<br \/>\n\" You don't really know the command at all and want to see it again soon.<br \/>\n\" ,c moves the current command down a several positions in the 'Study' queue<br \/>\n\" so you'll see it again soon.<br \/>\nnmap ,c ^v\/^$<cr>dma\/^$<\/cr><cr>\/^$<\/cr><cr>\/^$<\/cr><cr>\/^$<\/cr><cr>jP'azt<c -y><\/c><c -l>:noh<cr><\/p>\n<p>\" type ,k (that's comma k)<br \/>\n\" You have the command down cold.  Move it to the 'Known' queue.<br \/>\n\" ,k moves the current command into the 'Known' queue.<br \/>\nnmap ,k ^v\/^$<\/cr><cr>dma\/^= Known<\/cr><cr>jjP'azt<c -y><\/c><c -l><\/p>\n<p>\" Ok, it's time to get this party started.  Move to the top of the study queue<br \/>\n\" and go for it!<br \/>\n\/^= Study<br \/>\nnormal jztj<br \/>\nnohls<\/p>\n<p>\" This line keeps the rest of the file from being treated as vimscript<br \/>\nfinish<\/p>\n<p>-----------------------------------------------------------------------------<\/p>\n<p>= Study<\/p>\n<p>-<br \/>\nin normal mode, how do you move to the first non-whitespace character of the previous line<\/p>\n<p>+<br \/>\nin normal mode, how do you move to the first non-whitespace character of the next line<\/p>\n<p>g`\"<br \/>\nhow do you nondestructively move back to the last position when the buffer was closed<\/p>\n<p>:help shell<tab><br \/>\nhow can you see what *all* the commands starting with 'shell' when considering getting help<\/p>\n<p>:!mkdir -p %:h<br \/>\nif you have a file that you can't save because its directory doesn't exist, how can you create that directory from the path component of the file?<\/p>\n<p>:set textwidth=78<br \/>\nhow do you make vim hard wrap at 78 chars?<\/p>\n<p>:s\/\\v([a-z])([A-Z])\/\\1_\\L\\2\/g<br \/>\nturn camelCase into snake_case<\/p>\n<p>:s\/\\%V\\v([a-z])([A-Z])\/\\1_\\L\\2\/g<br \/>\nturn camelCase into snake_case (in only the visually selected part of the line)<\/p>\n<p>:s\/\\v_([a-z])\/\\u\\1\/g<br \/>\nturn snake_case into camelCase<\/p>\n<p>:s\/\\%V\\v_([a-z])\/\\u\\1\/g<br \/>\nturn snake_case into camelCase (in only the visually selected part of line)<\/p>\n<p>:'< ,'>normal @q<br \/>\nrun the macro recorded into the q register on all selected lines (the '< ,'> is automatically added)<\/p>\n<p>:let @q=\"2dw\"<br \/>\neasily fill the q register with a macro that deletes two words<\/p>\n<p>norm<br \/>\nwhat's a good shorthand for \"normal\" on the #vim_command_line<\/p>\n<p>:argdo norm @q<br \/>\nrun your last macro against all files in the args<\/p>\n<p>:.,. w !sh<br \/>\nexecute the contents of the current line in the current file in sh<\/p>\n<p><c -]><br \/>\nif you have ctags working correctly, how do you jump to the definition of a function?<\/p>\n<p><\/c><c -t><br \/>\nif you've made a ctag jump, how can you jump back other than <\/c><c -o>?<\/p>\n<p>gi<br \/>\nif you left insert mode to go look at something elsewhere in the file, how can you get back to where you were and also back into insert mode?<\/p>\n<p>:tag save<br \/>\nif you want to look up the definition of save using ctags<\/p>\n<p>:w !sh<br \/>\nrun the visually selected lines in the shell (not run as a filter)<\/p>\n<p>g?(some movement)<br \/>\nrot13 the text selected by some movement<\/p>\n<p>:all<br \/>\nopen in window for each file in the arguments list<\/p>\n<p>:args<br \/>\ndisplay the argument list<\/p>\n<p>:reg<enter><br \/>\nshow the contents of all registers<\/p>\n<p>:tj<\/enter><enter><br \/>\njump to tag on top of tag stack<\/p>\n<p>:reg a<\/enter><enter><br \/>\nshow the contents of register a<\/p>\n<p>:10,30!wc<\/enter><enter><br \/>\nfilter lines 10-30 through an external command (in this case wc)<\/p>\n<p><c -v>8<br \/>\ninsert the character represented by the ASCII value 8<\/p>\n<p>:43,45d<enter><br \/>\ndelete lines 43-45 (can specify any range before the d)<\/p>\n<p>H<br \/>\ngo to the top of the screen<\/p>\n<p>\"a20yy<br \/>\nadd the next 20 lines to the 'a' register<\/p>\n<p>g~(some movement)<br \/>\nswitch case for movement command<\/p>\n<p>o<br \/>\nin visual mode, exchange cursor position with the start\/end of highlighting<\/p>\n<p>!10jwc<\/enter><enter><br \/>\nfilter the next 10 lines through an external command (in this case wc)<\/p>\n<p>20!!wc<\/enter><enter><br \/>\nfilter the next 20 lines through an external command (in this case wc)<\/p>\n<p>20H<br \/>\ngo to the line that is 20 lines below the line that is currently the top of the window<\/p>\n<p>M<br \/>\ngo to the middle of the window<\/p>\n<p>L<br \/>\ngo to the bottom of the window<\/p>\n<p>10L<br \/>\ngo to the tenth line from the bottom of the window<\/p>\n<p>20%<br \/>\ngo to the line that is 20% of the way down in the file<\/p>\n<p>`a<br \/>\ngo to the exact position of mark a (not just the beginning of the line like 'a)<\/p>\n<p><c -d><br \/>\nGo down half a screen<\/p>\n<p><\/c><c -u><br \/>\nGo up half a screen<\/p>\n<p>0<br \/>\nmove to the start of the line (before whitespace)<\/p>\n<p><\/c><c -g><br \/>\nsee location in file and file status<\/p>\n<p>:set ignorecase (or :set ic)<br \/>\nignore case when searching<\/p>\n<p>R<br \/>\nenter replace mode to repeatedly replace the character under the cursor<\/p>\n<p>:w filename<br \/>\nwrite the visually selected text to a file<\/p>\n<p>e<br \/>\nGo to end of (next) word<\/p>\n<p>ge<br \/>\nGo to end of previous word<\/p>\n<p>U<br \/>\nrestore last changed line<\/p>\n<p>:set relativenumber<br \/>\nshow the line numbers relative to the current cursor position<\/p>\n<p>g*<br \/>\nForward find word under cursor (fuzzy)<\/p>\n<p>g#<br \/>\nBackward find word under cursor (fuzzy)<\/p>\n<p>#<br \/>\nBackward find word under cursor<\/p>\n<p>some_command | vim -R -<br \/>\nwhen in the shell, you can use vim as a pager by piping STDIN to it and putting it in readonly mode<\/p>\n<p>:set cursorline<br \/>\nhighlight the entire line the cursor is on<\/p>\n<p>Q<br \/>\nwhen in normal mode, how do you enter into Ex mode (to do extended work in the #vim_command_line)<\/p>\n<p>\/usr\/share\/vim<br \/>\nin Ubuntu, which folder has the default, system-wide vim files<\/p>\n<p>:map ,, :w\\|:!ruby %<br \/>\nhow would you map ,, to writing the current buffer, then running it with ruby<\/p>\n<p>:!!<br \/>\nrepeat the last :! command<\/p>\n<p>:set colorcolumn=78<br \/>\nin vim 703 and above, how do you specify that you'd like column 78 to be colored, so that you can see whether you are passing an ideal width<\/p>\n<p>text objects<br \/>\nwhat do you call the higher level contexts than editing character by character?<\/p>\n<p>readline vi mode (tagged as #readline_vi_mode)<br \/>\nwhat's it called when you use vim as your line editor in the shell?<\/p>\n<p>v<br \/>\nhow do you open an editor while the shell is in #readline_vi_mode<\/p>\n<p>g_<br \/>\nmove to the last non-whitespace character on a line<\/p>\n<p>bindkey -v<br \/>\nin zsh, how can you use #readline_vi_mode?<\/p>\n<p>ciw<br \/>\nchange a word without necessarily being selected on the first letter of the word<\/p>\n<p>daw<br \/>\nchange the phrase \"foo hello\" to just \"hello\" (with cursor located at f*oo hello)<\/p>\n<p><esc>v<br \/>\nif you're using vim as your line editor, how can you turn it in to a full vim session<\/p>\n<p>yy@\"<br \/>\nexecute the vim code in the current line.  To execute it in the shell, type :! at the beginning of the line<\/p>\n<p>mA<br \/>\nmark: set a mark in the 'A' register (globally)<\/p>\n<p>gu<br \/>\nmake the selected text lower case<\/p>\n<p>gU<br \/>\nmake the selected text upper case<\/p>\n<p><c -r>\"<br \/>\npaste yanked text into the #vim_command_line<\/p>\n<p>'A<br \/>\nmark: return to a globally set mark, even if in another buffer<\/p>\n<p><\/c><c -x><\/c><c -l><br \/>\nline completion<\/p>\n<p><\/c><c -i><br \/>\nmove forward in the jump list<\/p>\n<p><\/c><c -o><br \/>\nmove backward in the jump list<\/p>\n<p>gf<br \/>\nopen file under the cursor<\/p>\n<p>:%s\/\\r\/\/g<br \/>\nremove all those nasty ^M characters from the end of each line in a file<\/p>\n<p>=<br \/>\nautoindent lines already selected in visual mode<\/p>\n<p>==<br \/>\nautoindent current line<\/p>\n<p><\/c><c -o><br \/>\nin insert mode switch to normal mode for one command<\/p>\n<p>gqap<br \/>\nformat the current paragraph<\/p>\n<p>:jumps<br \/>\nlist your movements<\/p>\n<p>:history<br \/>\nlist your recent commands<\/p>\n<p>guu<br \/>\nlower case the whole line<\/p>\n<p>gUU<br \/>\nupper case the whole line<\/p>\n<p>display hex and ASCII value of character under cursor<br \/>\nga<\/p>\n<p>g8<br \/>\ndisplay hex value of utf-8 character under cursor<\/p>\n<p>ggg?G<br \/>\nrot13 whole file<\/p>\n<p>'.<br \/>\njumps to last modified line<\/p>\n<p>`.<br \/>\njumps to exact position of last modification<\/p>\n<p>:h slash<\/c><c -d><br \/>\nlist all help topics containing the word \"slash\"<\/p>\n<p>g;<br \/>\ngo backward in the change list in a file<\/p>\n<p>g,<br \/>\ngo forward in the change list in a file<\/p>\n<p>\"ayy<br \/>\nyank the current line into register \"a\"<\/p>\n<p>:set fdm=syntax<br \/>\nfold: make folding use syntax<\/p>\n<p>:set nofoldenable<br \/>\nfold: turn off folding<\/p>\n<p>:set foldenable<br \/>\nfold: turn on folding (if it has been turned off)<\/p>\n<p>zj<br \/>\nfold: moves the cursor to the next fold<\/p>\n<p>zk<br \/>\nfold: moves the cursor to the previous fold<\/p>\n<p>[z<br \/>\nfold: move to start of current open fold<\/p>\n<p>]z<br \/>\nfold: Move to end of current open fold<\/p>\n<p>:map <f6><br \/>\nshow what is currently mapped to <\/f6><f6><\/p>\n<p>:map<br \/>\nshow all the mappings<\/p>\n<p>:reg<br \/>\nshow the content of all registers<\/p>\n<p>:43,45 ce 80<enter><br \/>\ncenter the lines from 43 to 45 within an 80 char width<\/p>\n<p>zr<br \/>\nfold: decrease the fold level by one<\/p>\n<p>aw<br \/>\nin visual mode, select a whole word<\/p>\n<p>as<br \/>\nin visual mode, select a whole sentence<\/p>\n<p>zm<br \/>\nfold: increase the fold level by one<\/p>\n<p><c -6><br \/>\ntoggle between last two buffers<\/p>\n<p>gm<br \/>\ngo to the center of the screen on the current line<\/p>\n<p>]p<br \/>\nPaste below the current line, adjusting indentation to match current line<\/p>\n<p>gP<br \/>\npaste register above current line, leaving cursor after new text<\/p>\n<p>gp<br \/>\npaste register below current line, leaving cursor after new text<\/p>\n<p><\/c><c -r>a<br \/>\ninsert the content of register a while in insert mode<\/p>\n<p>[p<br \/>\nPaste above the current line, adjusting indentation to match current line<\/p>\n<p>:%norm @x<br \/>\nExecute the macro recorded in register x on all lines of the current file<\/p>\n<p>:norm @x<br \/>\nExecute the macro recorded in register x on a visually selected set of lines<\/p>\n<p><\/c><c -r>=5*5<br \/>\nin the #vim_command_line and in insert mode, insert the result of a 5*5 calculation<\/p>\n<p>gk<br \/>\nmove cursor one *screen* line up, regardless of line wrapping<\/p>\n<p>gj<br \/>\nmove cursor one *screen* line down, regardless of line wrapping<\/p>\n<p>qQ ... added commands ... q<br \/>\nappend more commands to a pre-existing @q register macro<\/p>\n<p>:Rextract _partial_name.erb<br \/>\nrails.vim: extract some functionality into a partial<\/p>\n<p>:Rintegrationtest<br \/>\nopen the cucumber feature with that name [tag:setup_specific:gem]<\/p>\n<p><\/c><c -p><br \/>\n(while searching or ex mode) do previous search or command<\/p>\n<p><\/c><c -n><br \/>\n(while searching or ex mode) do next search or command<\/p>\n<p><\/c><c -f><br \/>\n(while searching or ex mode) see previous searches or commands<\/p>\n<p>:%s\/forward\/\/gn<br \/>\ncount the number of occurrences of \"forward\" in a file<\/p>\n<p>q:<br \/>\nsee previous commands in a \"command-line window\"<\/p>\n<p>q\/<br \/>\nsee previous searches<\/p>\n<p>{<br \/>\nback a paragraph<\/p>\n<p>}<br \/>\nforward a paragraph<\/p>\n<p>(<br \/>\nback a sentence<\/p>\n<p>)<br \/>\nforward a sentence<\/p>\n<p>%<br \/>\nfind matching parenthesis<\/p>\n<p>J<br \/>\njoin two lines<\/p>\n<p>gq<br \/>\nreformat the selected text<\/p>\n<p>xp<br \/>\ntranspose two letters (delete and paste, technically)<\/p>\n<p>e<br \/>\nmove to the end of the word<\/p>\n<p>ea<br \/>\nappend at end of word<\/p>\n<p>w<br \/>\nmove the cursor forward by a word<\/p>\n<p>b<br \/>\nmove the cursor backward by a word<\/p>\n<p><\/c><c -v><br \/>\nin insert or the #vim_command_line this turns the next thing typed into a literal<\/p>\n<p>:set spell<br \/>\nSwitch on spell checking<\/p>\n<p><\/c><c -x><\/c><c -s><br \/>\nin insert mode correct the spelling of the current word<\/p>\n<p><\/c><c -v>jjjI\/\/<esc><br \/>\nblock comment the next three JavaScript lines<\/p>\n<p>\"+y<br \/>\ncopy the current selection to a clipboard where other programs can use it<\/p>\n<p>ci\"<br \/>\nchange all the words in between two quotes<\/p>\n<p>\/<c -r><\/c><c -w><br \/>\nswitch to search command mode, then copy in the word under the cursor<\/p>\n<p>:cn<br \/>\nGo to the next item in the quickfix list<\/p>\n<p>:cp<br \/>\nGo to the previous item in the quickfix list<\/p>\n<p>i<\/c><c -r>:<br \/>\ninsert last #vim_command_line command<\/p>\n<p>i<\/c><c -r>\/<br \/>\ninsert last search command<\/p>\n<p>:10,30w foo.txt<br \/>\nwrite lines 10-30 to a file named foo.txt<\/p>\n<p>:10,30w>>foo.txt<br \/>\nappend lines 10-30 to a file named foo.txt<\/p>\n<p>:r !ls<br \/>\ninsert results of ls external command below cursor<\/p>\n<p>:r file<br \/>\ninsert content of file below cursor<\/p>\n<p>&<br \/>\nrepeat last substitution<\/p>\n<p>:bm<br \/>\ngo to next modified buffer<\/p>\n<p>:w !sudo tee %<br \/>\nsave the current file as root (in case you opened it up without sudo accidentally and made changes to it)<\/p>\n<p><\/c><c -r>:<br \/>\nin Ex mode, insert the last command<\/p>\n<p><\/c><c -y><br \/>\nIn insert mode, insert the character right above the cursor<\/p>\n<p><\/c><c -u><br \/>\nIn insert mode, delete the current line from the cursor position to the beginning of the line<\/p>\n<p><\/c><c -a><br \/>\nIn insert mode, re-insert the text inserted in the previous insert session<\/p>\n<p><\/c><c -r>\/<br \/>\nin Ex mode, insert the last search<\/p>\n<p><\/c><c -f><br \/>\nWhen typing something into the #vim_command_line, switch to the editable command-line mode where the command line becomes a fully vim-compatible text area<\/p>\n<p>o<br \/>\nwhen in a visual selection, which key will toggle to the other end of the selection?<\/p>\n<p>:h i_CTRL-R<br \/>\nget help for how control r is used in insert mode<\/p>\n<p>:h c_CTRL-R<br \/>\nget help for how control r is used in command mode<\/p>\n<p>:s\/\\%V \/\/g<br \/>\nremove all the spaces from the current visual selection, which is only a partial line, not a full line<\/p>\n<p>:retab<br \/>\nif expandtab is set, this will change all the tabs to spaces, expanding them as appropriate<\/p>\n<p><\/c><c -w>_<br \/>\nmaximize size of window split<\/p>\n<p>I<br \/>\ninsert at the beginning of the line<\/p>\n<p>gv<br \/>\nremark area that was just marked<\/p>\n<p>ZZ<br \/>\nsame as :wq<\/p>\n<p><\/c><c -l><br \/>\nredraw the screen<\/p>\n<p><\/c><c -x><\/c><c -f><br \/>\ncompletes using filenames from the current directory.<\/p>\n<p><\/c><c -v><br \/>\nblock selection (column editing)<\/p>\n<p>zo<br \/>\nfold: open a fold at the cursor<\/p>\n<p>D<br \/>\ndelete to the end of the line<\/p>\n<p>C<br \/>\nchange to the end of the line<\/p>\n<p>:so $MYVIMRC<br \/>\nreload the vimrc file (or \":so %\" if you happen to be editing the file)<\/p>\n<p>A<br \/>\nappend at the end of the line<\/p>\n<p><\/c><c -x><br \/>\ndecrement a number on the same line when in normal mode (can be used with n before it)<\/p>\n<p><\/c><c -a><br \/>\nincrement a number on the same line when in normal mode (can be used with n before it)<\/p>\n<p>m<br \/>\nNERDTree: opens the filesystem menu for a file, allowing you to remove, rename, etc<\/p>\n<p>ma<br \/>\nmark: set a mark in the 'a' register in the current buffer<\/p>\n<p>`a<br \/>\nmark: return to the 'a' mark in the current buffer<\/p>\n<p><\/c><c -i><br \/>\nnext<\/p>\n<p><\/c><c -o><br \/>\nold<\/p>\n<p>~<br \/>\nuppercase or lowercase the character under the cursor<\/p>\n<p>.<br \/>\nrepeat the last command<\/p>\n<p><\/c><c -w><\/c><c -w><br \/>\nswitch between windows<\/p>\n<p>[I<br \/>\nshow lines containing the word under the cursor<\/p>\n<p>redir @a<br \/>\nredirect the output of an Ex command into buffer a<\/p>\n<p>g?<br \/>\nreverse the characters in a visual selection<\/p>\n<p>:gui<br \/>\nswitch to the gui version<\/p>\n<p>:g\/foo\/p<br \/>\nlist all the matches with prepended line numbers in ex command output<\/p>\n<p><\/c><c -a><br \/>\ninsert previously inserted text (in insert mode)<\/p>\n<p><\/c><c -w><br \/>\ndelete word before cursor in insert mode<\/p>\n<p><\/c><c -u><br \/>\ndelete all inserted text on the line (in insert mode)<\/p>\n<p>:echo line('.')<br \/>\nin the #vim_command_line, echo the current line number<\/p>\n<p>va(<br \/>\nvisually select *around* a set of parentheses.  Try it by moving the cursor (somewhere in here) and trying it<\/p>\n<p>redir @a | :g\/someregex\/<br \/>\nCapture the lines that match a certain regex into the @a register for pasting<\/p>\n<p>rm \/tmp\/clip.txt ; vim -c \"normal \\\"+p\" -c \"wq\" \/tmp\/clip.txt<br \/>\nSave the contents of the clipboard to a file by opening, pasting into, and closing vim.<\/p>\n<p>gD<br \/>\ngo to the first occurrence in the file of the word under the cursor<\/p>\n<p>gj<br \/>\ngo to next visual line, even if text wrapped<\/p>\n<p>%s\/\\v(.*\\n){5}\/&\\r<br \/>\ninsert a blank line every 5 lines<\/p>\n<p>''<br \/>\ngo to the position before the latest jump<\/p>\n<p>Fx<br \/>\nmove the cursor backward to the previous occurrence of the character x on the current line.<\/p>\n<p><\/c><c -b><br \/>\nscroll back one page<\/p>\n<p>:undolist<br \/>\nlist the leaves in the tree of the undo changes<\/p>\n<p>g+<br \/>\ngo to a newer text state (like <\/c><c -r>, but will move forward through all text states on multiple undo branches)<\/p>\n<p>g-<br \/>\ngo to an older text state (like <\/c><c -r>, but will move backwards through all text states on multiple undo branches)<\/p>\n<p>fx<br \/>\nmove the cursor forward to the next occurrence of the character x on the current line<\/p>\n<p>Tx<br \/>\nmove the cursor backward to right before the previous occurrence of the character x on the current line.<\/p>\n<p><\/c><c -w>x<br \/>\nexchange the window with the next window (like if you split a new buffer into the wrong window location)<\/p>\n<p>M<br \/>\nmove the cursor to the middle of the screen<\/p>\n<p>zt<br \/>\nscroll current line to top of page<\/p>\n<p>tx<br \/>\nsame as fx, but moves the cursor to right before the character, not all the way to it.<\/p>\n<p><\/c><c -f><br \/>\nscroll forward one page<\/p>\n<p>zz<br \/>\nmove current line to middle of page<\/p>\n<p>;<br \/>\nrepeat the last f\/F\/t\/T command you gave<\/p>\n<p><\/c><c -e><br \/>\nscroll one line up<\/p>\n<p><\/c><c -y><br \/>\nscroll one line down<\/p>\n<p>]m<br \/>\nforward to start of next method<\/p>\n<p>[m<br \/>\nbackward to start of previous method<\/p>\n<p>zh<br \/>\nscroll one character to the right<\/p>\n<p>zl<br \/>\nscroll one character to the left<\/p>\n<p>zH<br \/>\nscroll half a screen to the right<\/p>\n<p>zL<br \/>\nscroll half a screen to the left<\/p>\n<p>zb<br \/>\nscroll current line to bottom of page<\/p>\n<p>set -o vi<br \/>\nin a the bash shell, how can you use #readline_vi_mode?<\/p>\n<p><\/c><c -t><br \/>\nreturn from tag jump.  For example, in help, if you've followed a link, how do you go back?<\/p>\n<p><\/c><c -]><br \/>\njump to tag under cursort (for example, following a link in help)<\/p>\n<p>K<br \/>\nlook up the word under the cursor in man<\/p>\n<p>tabularize<br \/>\nWhat's the name of a plugin that will help you align stuff<\/p>\n<p>VG:norm @x<br \/>\nreplay a vim macro recorded into register x on all lines between the current line and the bottom of the buffer<\/p>\n<p>%g\/foo\/s\/bar\/xxx\/g<br \/>\nOn every line containing foo *anywhere* in the line (before or after the bar), replace every occurrence of bar with xxx<\/p>\n<p>:'< ,'>!uniq | sort<br \/>\nWith some lines selected, how can I run them through external commands, substituting the result?<\/p>\n<p>:put =@%<br \/>\ninsert the file directory\/filename for the current file into the buffer<\/p>\n<p>\"Ayy<br \/>\nAppend the yank of the current line into the 'a' buffer<\/p>\n<p>%v\/bar\/m$<br \/>\nmove every line that *does not* contain bar to the end of the file<\/p>\n<p>:verb set ballooneval?<br \/>\nhow can you check who last set ballooneval<\/p>\n<p>%s\/\\v(\"[a-z_]+\"): \/\\1 => \/g<br \/>\nreplace \"foo\": with \"foo\" => (to turn JSON into acceptable Ruby)<\/p>\n<p>%s\/\\v +$\/\/g<br \/>\nremove trailing spaces from all lines<\/p>\n<p>cs\"'<br \/>\nhow would you change the text \"foo hello there\" to 'foo hello there' using vim-surround?<\/p>\n<p>:cold<br \/>\nshow the older error list in the quickfix window (error lists are referred to as being in the quickfix stack)<\/p>\n<p>:cnew<br \/>\nshow the newer error list in the quickfix window (error lists are referred to as being in the quickfix stack)<\/p>\n<p>@:<br \/>\nrepeat the last command-line<\/p>\n<p>\"_dd (\"_ is the black hole buffer)<br \/>\ndelete a line without overriding the buffer<\/p>\n<p><\/c><c -w><enter><br \/>\nopen the file listed in quickfix in a horizontal split<\/p>\n<p>:g\/^\/m0<br \/>\nreverse the vertical order of all the lines<\/p>\n<p>:only<br \/>\nif you have a bunch of windows open, close all the other windows, making the current window the only window<\/p>\n<p>vim +NERDTree<br \/>\nFrom the shell command line (not vim's command line) how can you easily run a vim command?<\/p>\n<p>:AS<br \/>\nwith rails.vim, how do you open the rspec tests when you are in a model?<\/p>\n<p>&<br \/>\nrepeat last substitution<\/p>\n<p>ds\"<br \/>\nif you have the surround plugin, how would you remove the double quotes from \"hello\" when inside it?<\/p>\n<p>vim filename -c 'execute \"normal \\<c -x>\"'<br \/>\nhow can you decrement the first number on the first line of the file? (how would you property escape the <\/c><c -x>?)<\/p>\n<p>\/\\cruby<br \/>\ndo a case-insensitive search for ruby (the \\c can be anywhere, including at the end)<\/p>\n<p>= Known<\/p>\n<p>:wq<br \/>\nwrite the file and quit.  This is basically here just so that there's something in the \"Known\" queue.<br \/>\n<\/c><\/enter><\/c><\/esc><\/c><\/enter><\/f6><\/c><\/esc><\/c><\/enter><\/c><\/enter><\/c><\/tab><\/c><\/cr><\/c><\/cr><\/c><\/cr><\/code><\/p>\n<p>Here you can <a href=\"http:\/\/screencast.com\/t\/pUiUrivSRF42\">see it in action.<\/a><\/p>\n<p>To start, just copy the contents of the file above into a vim buffer, save it, then source the file by typing <code>:so %<\/code><\/p>\n<p>Now, hit <code>,,<\/code> to move the first card from the top of the Study queue to the bottom. Rinse and repeat.<\/p>\n<p>Over time your vim study lab can end up as a nice repository of newly acquired knowledge. Just add new cards as you pick up new tricks.<\/p>\n<p>&nbsp;<\/p>\n<p>From From <a href=\"http:\/\/nerds.weddingpartyapp.com\/tech\/2013\/11\/17\/mastering-vim-in-vim\/\" target=\"_blank\" rel=\"noopener noreferrer\">nerds.weddingpartyapp.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>From nerds.weddingpartyapp.com Mastering Vim in Vim Vim has a deserved reputation for being difficult to learn. The included vimtutor program will teach you the absolute basics, enough to allow you to edit a file, but what if you want to achieve the extreme proficiency you\u2019ve heard vim users are capable of?&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/6063\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-6063","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Mastering Vim in Vim - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/6063\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mastering Vim in Vim - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"From nerds.weddingpartyapp.com Mastering Vim in Vim Vim has a deserved reputation for being difficult to learn. The included vimtutor program will teach you the absolute basics, enough to allow you to edit a file, but what if you want to achieve the extreme proficiency you\u2019ve heard vim users are capable of?... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/6063\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2014-03-09T15:07:04+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/nerds.weddingpartyapp.com\/images\/posts\/learning_curves.jpg\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Mastering Vim in Vim\",\"datePublished\":\"2014-03-09T15:07:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/\"},\"wordCount\":362,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"image\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/nerds.weddingpartyapp.com\\\/images\\\/posts\\\/learning_curves.jpg\",\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/\",\"name\":\"Mastering Vim in Vim - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/nerds.weddingpartyapp.com\\\/images\\\/posts\\\/learning_curves.jpg\",\"datePublished\":\"2014-03-09T15:07:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/#primaryimage\",\"url\":\"http:\\\/\\\/nerds.weddingpartyapp.com\\\/images\\\/posts\\\/learning_curves.jpg\",\"contentUrl\":\"http:\\\/\\\/nerds.weddingpartyapp.com\\\/images\\\/posts\\\/learning_curves.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/6063\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mastering Vim in Vim\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mastering Vim in Vim - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/6063\/","og_locale":"en_US","og_type":"article","og_title":"Mastering Vim in Vim - Linux Shtuff","og_description":"From nerds.weddingpartyapp.com Mastering Vim in Vim Vim has a deserved reputation for being difficult to learn. The included vimtutor program will teach you the absolute basics, enough to allow you to edit a file, but what if you want to achieve the extreme proficiency you\u2019ve heard vim users are capable of?... Read More","og_url":"https:\/\/g33kinfo.com\/info\/6063\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2014-03-09T15:07:04+00:00","og_image":[{"url":"http:\/\/nerds.weddingpartyapp.com\/images\/posts\/learning_curves.jpg","type":"","width":"","height":""}],"author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/6063\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/6063\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Mastering Vim in Vim","datePublished":"2014-03-09T15:07:04+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/6063\/"},"wordCount":362,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"image":{"@id":"https:\/\/g33kinfo.com\/info\/6063\/#primaryimage"},"thumbnailUrl":"http:\/\/nerds.weddingpartyapp.com\/images\/posts\/learning_curves.jpg","articleSection":["General Info"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/6063\/","url":"https:\/\/g33kinfo.com\/info\/6063\/","name":"Mastering Vim in Vim - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"primaryImageOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/6063\/#primaryimage"},"image":{"@id":"https:\/\/g33kinfo.com\/info\/6063\/#primaryimage"},"thumbnailUrl":"http:\/\/nerds.weddingpartyapp.com\/images\/posts\/learning_curves.jpg","datePublished":"2014-03-09T15:07:04+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/6063\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/6063\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/6063\/#primaryimage","url":"http:\/\/nerds.weddingpartyapp.com\/images\/posts\/learning_curves.jpg","contentUrl":"http:\/\/nerds.weddingpartyapp.com\/images\/posts\/learning_curves.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/6063\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Mastering Vim in Vim"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/6063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=6063"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/6063\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=6063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=6063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=6063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}