text: (window.webpackJsonp=window.webpackJsonp||[]).push([[19],{"8hLB":function(e,t,a){"use strict";var b=a("q1tI"),n=a.n(b),l=(a("Wbzz"),a("Bl7J"));t.a=function(e){return n.a.createElement(l.a,Object.assign({},e,{icon:"post"}))}},JUuC:function(e,t,a){"use strict";a.r(t),a.d(t,"_frontmatter",(function(){return s})),a.d(t,"default",(function(){return A}));var b=a("zLVn"),n=(a("q1tI"),a("7ljp")),l=a("8hLB"),s={},c={_frontmatter:s},i=l.a;function A(e){var t=e.components,a=Object(b.a)(e,["components"]);return Object(n.b)(i,Object.assign({},c,a,{components:t,mdxType:"MDXLayout"}),Object(n.b)("p",null,Object(n.b)("a",Object.assign({parentName:"p"},{href:"http://www.vim.org/"}),"Vim")," is as powerful as your power armor but can be extremely lighter! I believe you click in to learn more about it. But here we don't talk much about ",Object(n.b)("a",Object.assign({parentName:"p"},{href:"https://github.com/daizeng1984/dotfiles/blob/master/neovim/nvim/config/plugins.vimrc"}),"plugins"),". Just some tips I found along daily use of vim ..."),Object(n.b)("h2",null,"Vim Ads"),Object(n.b)("p",null,"Sorry before we jump in, here's the ads 😄."),Object(n.b)("figure",{className:"gatsby-resp-image-figure",style:{position:"relative",display:"block",marginLeft:"auto",marginRight:"auto",width:"40%",textAlign:"center",minWidth:"7rem",backgroundColor:"rgb(255, 255, 255)",border:"1px solid rgb(222, 226, 230)",maxWidth:"600px"}},"\n    ",Object(n.b)("span",Object.assign({parentName:"figure"},{className:"gatsby-resp-image-wrapper",style:{position:"relative",display:"block",marginLeft:"auto",marginRight:"auto",maxWidth:"600px"}}),"\n      ",Object(n.b)("a",Object.assign({parentName:"span"},{className:"gatsby-resp-image-link",href:"/static/86d5bcf69612d038b66243e52c5fb8b6/b9962/vim-ads.jpg",style:{display:"block"},target:"_blank",rel:"noopener"}),"\n    ",Object(n.b)("span",Object.assign({parentName:"a"},{className:"gatsby-resp-image-background-image",style:{paddingBottom:"148.66666666666666%",position:"relative",bottom:"0",left:"0",backgroundImage:"url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAeABQDASIAAhEBAxEB/8QAGgAAAgIDAAAAAAAAAAAAAAAAAAUDBAECBv/EABYBAQEBAAAAAAAAAAAAAAAAAAACAf/aAAwDAQACEAMQAAABjmt52V4xMbVU9mLZnPh//8QAGxAAAgMBAQEAAAAAAAAAAAAAAQIAAxETFDH/2gAIAQEAAQUC5CckgrWVqGFgTWAUqNS34z6UtyetobTv/8QAGREAAgMBAAAAAAAAAAAAAAAAAAECEBEh/9oACAEDAQE/AciqRw//xAAYEQADAQEAAAAAAAAAAAAAAAAAAREQIv/aAAgBAgEBPwGvHTo//8QAHhAAAgICAgMAAAAAAAAAAAAAAAECESExEFESQYH/2gAIAQEABj8CSR2PBGV6VMWfEpIj3RUfRexXkwor5x//xAAdEAADAQEAAgMAAAAAAAAAAAAAAREhMUFhUaHx/9oACAEBAAE/IdJZFnwTx1n6Kk1HNVN/XEGEfZ0mAkV0wkaMq7rvolInS6NozjwPYT+dD//aAAwDAQACAAMAAAAQtDB8/8QAFhEBAQEAAAAAAAAAAAAAAAAAAREA/9oACAEDAQE/EA1lcBoNM//EABgRAQEBAQEAAAAAAAAAAAAAAAEAESFh/9oACAECAQE/EFebhK2ke7//xAAhEAEAAgEDBAMAAAAAAAAAAAABABEhMUFRYZGxwXGBof/aAAgBAQABPxAsBJFa3oq95ZsKooAceSU8TnDsL/ZiwoGtVvvMIawS3cEEgRguvcKn0WE6GL9RK20ONrqpenuCAgYBmP8AOWoPzSRGCPFvLNIT6I7E/9k=')",backgroundSize:"cover",display:"block"}})),"\n  ",Object(n.b)("img",Object.assign({parentName:"a"},{className:"gatsby-resp-image-image",alt:"Vim Today!",title:"Vim Today!",src:"/static/86d5bcf69612d038b66243e52c5fb8b6/b4294/vim-ads.jpg",srcSet:["/static/86d5bcf69612d038b66243e52c5fb8b6/75985/vim-ads.jpg 150w","/static/86d5bcf69612d038b66243e52c5fb8b6/f93b5/vim-ads.jpg 300w","/static/86d5bcf69612d038b66243e52c5fb8b6/b4294/vim-ads.jpg 600w","/static/86d5bcf69612d038b66243e52c5fb8b6/8e1fc/vim-ads.jpg 900w","/static/86d5bcf69612d038b66243e52c5fb8b6/e5166/vim-ads.jpg 1200w","/static/86d5bcf69612d038b66243e52c5fb8b6/b9962/vim-ads.jpg 1334w"],sizes:"(max-width: 600px) 100vw, 600px",style:{width:"100%",height:"100%",margin:"0",verticalAlign:"middle",position:"absolute",top:"0",left:"0"},loading:"lazy"})),"\n  "),"\n    "),"\n    ",Object(n.b)("figcaption",Object.assign({parentName:"figure"},{className:"gatsby-resp-image-figcaption"}),"Vim Today!"),"\n  "),Object(n.b)("h2",null,"Tips"),Object(n.b)("ul",null,Object(n.b)("li",{parentName:"ul"},"Remap Capslock: For a vim user, capslock can be nightmare. In mac you could easily remap it with ",Object(n.b)("a",Object.assign({parentName:"li"},{href:"https://pqrs.org/osx/karabiner/"}),"Karabiner")," to something like ",Object(n.b)("kbd",null,"Esc"),". In my dotfiles configuration, I remapped it to ",Object(n.b)("kbd",null,"F10")," and make it a prefix key for tmux."),Object(n.b)("li",{parentName:"ul"},"Selection: ",Object(n.b)("kbd",null,"v")," ",Object(n.b)("kbd",null,"i")," ",Object(n.b)("kbd",null,"t")," means select within tag. You can visual select in ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"t"),"ag or ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"b"),"lock or ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"w"),"ord. Also you should arm with Pope's ",Object(n.b)("a",Object.assign({parentName:"li"},{href:"https://github.com/tpope/vim-surround"}),"surround plugin")," (you need some practices to master power of surround). Similarly working for ",Object(n.b)("kbd",null,"y")," ",Object(n.b)("kbd",null,"d")," etc. as well."),Object(n.b)("li",{parentName:"ul"},"Numbers: when you have some text and number editing e.g. adding increasing number for each line. You could do this in command  ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":put =range(1,10, 2)")),Object(n.b)("li",{parentName:"ul"},"Tabs: ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":retab")," will just remove every tabs into spaces (nice 😌)"),Object(n.b)("li",{parentName:"ul"},"Jump between tags: you could visually select around tag ",Object(n.b)("kbd",null,"v"),"+",Object(n.b)("kbd",null,"a"),"+",Object(n.b)("kbd",null,"t")," and use ",Object(n.b)("kbd",null,"o")," to switch."),Object(n.b)("li",{parentName:"ul"},"Global variable: sometimes, you'd like to see the tab, and strange non-printable chars in your vim you could do ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":set list"),"; for some files, you'd like to know the file format by ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":set ff?")," and yes this is actually a command to see and set global variables in vim! ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":set varname")," or ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":set varname?")),Object(n.b)("li",{parentName:"ul"},"Macro: ",Object(n.b)("kbd",null,"q")," and then a register name to record it. ",Object(n.b)("kbd",null,"@")," or ",Object(n.b)("kbd",null,"shift"),"+",Object(n.b)("kbd",null,"2")," to apply it. It's simple but extremely useful. There are some complicate macro tricks to do numbers, or incrementally, but since I don't usually use them and they just overflow, out of my memory :laughing:..."),Object(n.b)("li",{parentName:"ul"},"Bookmark: ",Object(n.b)("kbd",null,"m")," + a char to add and ",Object(n.b)("kbd",null,"'")," + the char to jump there and ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":marks")," to show all"),Object(n.b)("li",{parentName:"ul"},"Mysteriuos ",Object(n.b)("kbd",null,"g"),": ",Object(n.b)("kbd",null,"g"),Object(n.b)("kbd",null,"f")," to open the file under cursor and ",Object(n.b)("kbd",null,"g"),Object(n.b)("kbd",null,"x")," to open it in xwindow system... ",Object(n.b)("kbd",null,"ctrl"),"+",Object(n.b)("kbd",null,"g")," to show file path information"),Object(n.b)("li",{parentName:"ul"},"History of command: ",Object(n.b)("kbd",null,"q:")," and for macros we have ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":registers"),"/",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":reg")," or ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":echo @a")," for a single register ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"a")),Object(n.b)("li",{parentName:"ul"},"Window zoom fullscreen: ",Object(n.b)("kbd",null,"ctrl"),"+",Object(n.b)("kbd",null,"w"),", ",Object(n.b)("kbd",null,"o")),Object(n.b)("li",{parentName:"ul"},Object(n.b)("kbd",null,"ctrl"),"+",Object(n.b)("kbd",null,"r")," in Insert Mode and then ",Object(n.b)("kbd",null,"=")," allows you do math or something more powerful e.g. `=range(1,10)`!"),Object(n.b)("li",{parentName:"ul"},"% is currentbuffer in ex command e.g. ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":Remove %"),"."),Object(n.b)("li",{parentName:"ul"},Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"'<")," and ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"'>")," are start and end line of visual block. Therefore, for example, to replace extra spaces in your selection, you can do vim's ",Object(n.b)("a",Object.assign({parentName:"li"},{href:"http://vimregex.com/"}),"Regular Expression"),": ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"'<'>s/\\s\\s\\+/ /g"),"."),Object(n.b)("li",{parentName:"ul"},"reverse all lines ",Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":g/^/m0")," which actually takes reg exp matched lines and then move them to line 0."),Object(n.b)("li",{parentName:"ul"},Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),"jumplist"),": jump to last edit/change location ",Object(n.b)("kbd",null,"g"),"+",Object(n.b)("kbd",null,";")," and ",Object(n.b)("kbd",null,"g"),"+",Object(n.b)("kbd",null,",")),Object(n.b)("li",{parentName:"ul"},Object(n.b)("code",Object.assign({parentName:"li"},{className:"language-text"}),":vert diffs <tab>")," to simply vsplit buffer to diff")),Object(n.b)("h2",null,"Reference"),Object(n.b)("p",null,"I found some really really nice presentation that worth a look: Erik Falor's ",Object(n.b)("a",Object.assign({parentName:"p"},{href:"https://www.youtube.com/watch?v=MquaityA1SM"}),'"From Vim Muggle to Wizard in 10 Easy Steps"'),"; when you get totally naked in an alien linux server, watch ",Object(n.b)("a",Object.assign({parentName:"p"},{href:"https://www.youtube.com/watch?v=XA2WjJbmmoM&t=907s"}),"this"),"."))}A.isMDXComponent=!0}}]);
  //# sourceMappingURL=component---src-posts-2017-08-01-why-we-love-fallout-mdx-580ea2d127181a3ff3d0.js.map