Vim, reddit

Understand Vim Mappings and Create Your Own Shortcuts

2018-05-16 22:46:02

submitted by /u/jolenzy
[link] [comments]

Read more

Would it make sense to use some other key than to switch out of insert mode because some keys generate sequences which can cause a mess if struck by accident while inserting?

2018-05-16 15:17:31

How would you set it up in your vimrc file, to use some other key instead of <esc>?

submitted by /u/aiaor
[link] [comments]

Read more

Use errorfile on log

2018-05-16 13:02:02

I have a program logging lots of info in a log and my errorformat is capable to detect errors in there. If I use :cfile to open the log, the entire log is opened in a quickfix window, which is not very useful, while I'd like only the matching errorformat lines to show. How can I do this?

submitted by /u/albasili
[link] [comments]

Read more

Auto Complete Function Arguments

2018-05-16 11:05:17

Hi, so I am new to Vim, just transitioned from Emacs (sorry)

I basically have everything in Vim that I had in Emacs now, but I can't seem to get this functionality:

As you can see, in Emacs I was able to autocomplete function arguments with Tab, as long as the file that was to be completed from was open in another buffer.

So if I wanted to autocomplete void testFunc(int a, char b, float c) it would work like this:

v <TAB> = void

test <TAB> = testFunc

(<TAB> = (int

<SPACE><TAB> = a


In Vim, it only ever autocompletes the function name, I can't get it to work for the arguments. Sorry, if this didn't make much sense, I attached the GIF to hopefully make my explanation easier to understand. I would really appreciate any help on this matter.


submitted by /u/Blu342
[link] [comments]

Read more

Auto-detect file encoding?

2018-05-16 05:28:55

I ran into a little trouble with file encodings last week. I had downloaded a file in a non-UTF8 mystery encoding (Simplified Chinese), and vim was opening it in Latin1.

Of course, vim provides a lot of features for manipulating the file encoding:

  • 'fileencodings' sets the encodings that vim will try when opening a new file;
  • 'fileencoding' sets the output encoding of the current buffer (i.e., for saving to a different encoding, not reading as a different encoding);
  • the ++enc option allows commands (like :e) to be performed with an ad hoc file encoding set (useful for reloading files in another encoding).

None of these, however are useful for handling unknown file encodings. In the end, I opened the file in Kate, which automatically (and correctly) guessed the encoding to be GB18030.

I imagine it’s not trivial to accurately guess the encoding of a text file, but clearly, it’s possible, at least in some cases. Does vim provide this capability? If not, is there a plug-in for it?

submitted by /u/ryanlue
[link] [comments]

Read more