2

While in insert mode in a .R file, the %>% pipe is added when I hit <CR>.

When I checked:

:map! I get i <CR> *@<Esc>:normal! a %>%<CR>a

:verbose imap <CR> I get Last set from ~/.local/share/nvim/view/~=+random.R=1.vim line 161.

I tried editing the file by either deleting or commenting out the line 161 which reads inoremap <buffer> ^V^M ^V^[:normal! a %>%^V^Ma however each time even though the save is successful, if I open a new .R file, <CR> again produces a %>% and upon reopening ~/.local/share/nvim/view/~=+random.R=1.vim, line 161 is restored.

I've tried editing with nano, vim, nvim and plain old TextEdit to no avail.

Additionally, the file ~/.local/share/nvim/view/~=+random.R=1.vim was created at the same time as when I first installed NeoVim and configured Vim-R.

:ver
NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedant
ic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdia
gnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20191107-85913-1wbgqz6/n
eovim-0.4.3/build/config -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/src -I/usr/local/include -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/deps-bui
ld/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include
-I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/src/nvim/auto -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/include
Compiled by brew@Catalina.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.3/share/nvim"
  • I reinstalled the entire set up four times having deleted all files from each of the previous attempts. On the fourth try the issue did not reappear. So I guess I do not need an answer for now. Would be nice to know why I couldn't edit and save the file successfully though.. – Anurag N. Sharma Aug 8 at 11:33
  • 2
    This looks like a "view" file created with :mkview (note that there's also :mksession which saves a view for all windows.) Do you perhaps have an autocmd or plug-in that will save a session automatically? In that case, once that mapping gets restored once, it will keep getting saved over and over again on each mksession... Though it's odd what you mentioned about the file's timestamp... It's usually fine to just remove "view" files when they're not doing what you want. Do it when Vim is closed, so it won't create a new one when you exit. – filbranden Aug 8 at 13:06
  • 1
    I did indeed have some autocmd bits that I used from some Medium/other articles. I can't recall the exact one, but yes, having removed all the files after the THIRD failed try, on the fourth attempt, the issue didn't reappear at all and I am able to edit the files once again. I will keep a look out in the future for such issues now that I know what I could spot. – Anurag N. Sharma Aug 8 at 13:36
  • If you solved it, add an answer! I agree with filbranden that this looks like a spuriously creates view; deleting in and making sure vim doesn’t create views you dont want can help. – D. Ben Knoble Aug 9 at 12:59
  • Done now, @D.BenKnoble, apologies. – Anurag N. Sharma Aug 10 at 6:45
0

I was pointed to this particular discussion by the author of Nvim-R and after reading @filbranden's comment. This is most definitely what caused the issue and not Nvim-R as I thought. I still can't explain how the %>% appeared in the first place, though.

In brief, the addition of the following line in the init.vim or .vimrc file prevents anything other than code foldings and cursor position to be saved

let &viewoptions="folds,cursor,unix"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.