Skip to content

Instantly share code, notes, and snippets.

@xyos
Created June 12, 2019 21:12
Show Gist options
  • Save xyos/8a56b6e7132936ad9688afb2c4180de3 to your computer and use it in GitHub Desktop.
Save xyos/8a56b6e7132936ad9688afb2c4180de3 to your computer and use it in GitHub Desktop.

The power of Vim

Example 1 (power of dot)

example.h

bool Process1(int nitems);
bool Process2(int position);
bool Process3(int ntrials, bool property);
Example

Example 2 (smart ranges)

example.ts

if (!entry.used && equivalent(entry.key()), qk.key && entry.contexts) {
}

Example 3 (delimited blocks)

example.html cit change inside tag dat delete around tag

<div class="something">
  <a href="/somelink">
    <span>asd</span>
  </a>
</div>

Example 4 (other motions) vim is not only hjkl

H // (higher) L // (lower) M // (middle)

// scrolling zt // scrolling to top zz // scrolling to middle zb // scrolling to bottom

Example 5 (other commands) power of visual

const someconstant1 = 1;
  const someconstant5 = 1;
const   someconstant2 = 1;
const   someconstant4 = 1;
const someconstant6 = 1;  
const someconstant3 = 1;  

Example 6 (Ex Mode)

:g/pattern/d delete lines (power of g) :g/pattern/exe "somecommand" execute somecommand on lines matching pattern :s/pattern/newpattern/ search and replace

const someFunction(somevar: number) {
  switch (somevar) {
    case 1:
      doSome(somevar);
      break;
    case 2:
      doSome(somevar + 3);
      console.log(2);
      break;
    case 3:
      doSome(somevar);
      break;
    case 4:
      doSome(somevar);
      console.log(2);
      break;
    case 5:
      doSome(somevar);
      console.log(2);
      break;
    default:
      break;
  }
}

Example 7 Macros

q<some key> starts recording @<some key> stops recording @@ run last macro

qaI"f:c$"jq

qa # starts recording in register a I" # insert " at the soft start of line then go back to normal f:c$" # find next : then change with " and go back to normal j # go down one line q # end recording

192.168.0.3:33
192.168.0.4:12
19.168.0.5:1234
192.168.0.6:4341
192.168.0.7:4444
192.168.0.2:1
200.168.0.8:1234
201.168.0.9:4200
20.168.0.10:223

Plugins

undotree new thing I won't remember

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment