Vim Usage

ctrl+o and ctrl+shit+i is the combo for going back and forth using vim jumps. Normally it should be ctrl+i or tab to jump forward. If it’s not working then I found you can use ctrl+shift+i.

Will keep updating this post with other vim related things that i want to track and share.

Golang Import Error

Sometimes if you install golang package using go get in terminal outside vim editor. It’s still showing import error. Until its fixed by gopls or whatever plugin is handling that you can just kill the goplz process.

1
pkill gopls

Killing gopls will let neovim/vim to get rid of this false import erorr.

Line Wrap

To wrap line wrapped for the vim current window width use following.

1
set wrap

Neoterm

Just to run some command and get the output in a terminal that is loaded inside a buffer.

1
ctrl-\ ctrl-n

Selcting function body

The better way to select a function content is to go inside a function with your cursor and type vi} it will select everything between { and }.

Another method is using v{o} this will also select function body.

In case you want to select body and the function signature you can do va{V

Persistent folding

I have found this resource this solves my problem of keeping the folds and loading them when I am openning file again.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup


-- Persistent Folds
local save_fold = augroup("Persistent Folds", { clear = true })
autocmd("BufWinLeave", {
  pattern = "*.*",
  callback = function()
    vim.cmd.mkview()
  end,
  group = save_fold,
})
autocmd("BufWinEnter", {
  pattern = "*.*",
  callback = function()
    vim.cmd.loadview({ mods = { emsg_silent = true } })
  end,
  group = save_fold,
})

Thanks for reading.

-Najam

comments powered by Disqus