fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

8.8K
active users

#vimtips

0 posts0 participants0 posts today

Ooh, vim actually makes a way better manpager than whatever else usually shows the man stuff, it even works with links and everything :D so ctrl+] and it also rewrites the q shortcut to just quit, it's really nice.

```
export MANPAGER='nvim +Man!'
```

#vim #vimtips #til

TIL about `<C-a>` and `<C-x>` in #vim for adding or subtracting.
(`:h ctrl-a` , `:h ctrl-x` )

Ctrl-a will add [count] to a number or alphabetic character at or after the cursor.
And Ctrl-x will do subtraction in the same way.

For example let's say I need to increment this 1 to be a 2.

```
replicas: 1
```

Normally I would type `f1` followed by `r2`
Or maybe even just `A` <backspace> `2`

But we can do better.

In this particular scenario I need only be on that line and do `<C-a>`
Since `<C-a>` will look ahead to find a digit on the current line and act upon it. Which means we can do this from the start of the line and it will turn into:

```
replicas: 2
```

And if I want to change it back to `1` I can use `<C-x>`

These two commands will even take a `[count]`. This means that if the current value is `replicas: 1` we can do `10<C-a>` and it will now say `replicas: 11`

#vimtips#VimTip#TIL

Copy to system clipboard from #vim guide:

1. In your ~/.vimrc set
set clipboard=unnamed

2. Open a file and yank whatever you want, in this example we yank lines 4 and 5 to system clipboard; in command mode, type 4,5y *
set ts=2
set sts=2
set sw=2
filetype off
filetype plugin indent on
syntax on
set expandtab

3. Profit
Paste anywhere you want
filetype off
filetype plugin indent on

Fun vim tip before lunch: imagine you've selected a block and still in VISUAL mode but need to select some lines above the selection.

- Press "o"
- Move the cursor
- Press "o" again if you want a couple of times ;) ;)

And there you go, you can change the cursor in visual mode from top to bottom with just 1 key press.

And when you need the full completion madness in the command line, for example when you're editing complex Regular Expression statements, simply type `q:` from normal mode and you get the full Vim editing power in an editable command history window.
Simply type your command line statement (or select an older one) and press <CR> to execute the command line under the cursor. See :help q:

#Vim#Vi#Editor