6

You can surround the word currently under the cursor in quotes with the following normal mode commands: ciw""EscP Replace iw with any other Vim motion/text object to surround other things with quotes*. Or "" with any other pair of characters to surround the object with different things. If you want to surround the object with a longer piece of text, such ...


5

Yes, a plug-in for surrounding with quotes exists! vim-surround is what you're looking for. To surround the current word in double quotes, you can use ysiw" once you have the plug-in installed. ys is the command to surround and object (there's also cs to replace one delmiter with another, ds to remove surrounding), then iw is a text-object defining what to ...


3

How can a plugin find where it is itself located? You need to expand() <sfile>. Assuming your code resides in myplug/plugin/<somefile.vim>: # the first :h is to skip the script name; # the second is to skip "plugin/" part let s:mydefaultdir = expand("<sfile>:h:h") . "/mydefaultdir" ... let g:scriptdir = get(g:, 'scriptdir', s:mydefaultdir)...


2

To get the current line you can use :h getline() giving it the parameter '.'. This will return a string, all you have to do next is to get the length of this string, to do so you have several options: :h string-functions strlen() length of a string in bytes strchars() length of a string in characters strwidth() size of string when displayed ...


2

Searching the web for this sort of thing merely turns up tricks for searching the command history manually (without vimscript). I believe you're overthinking something. In Vim "key macros" are the "first-class citizens". They are stable and repeatable (if written well). There's no need to turn them into the "true" VimScript statements other than some minor ...


2

If you are using a unix-like system, in vim, type ex-command :%! rev


1

I believe this happens, because you are executing a normal mode command that resolves to a ex command but that is not put into the history as you noted. Now you could throw into an extra histadd() call, but I believe this is more or less a hack. I would suggest a different, more robust approach, that does not depend on the order of :set syn= commands you ...


1

According to Vim documentation (:help -c) there can only be a maximum of 10 +{command}, -c {command} and -S {file} option arguments combined when starting Vim, and they execute _after_ the first file is read. The --cmd {command} option allows an additional 10 commands to be executed before processing any vimrc file, but bear in mind that any settings can be ...


Only top voted, non community-wiki answers of a minimum length are eligible