Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

You can use digraphs: Ctrl+k-N (with a capital N) In Insert mode, digraphs are entered by Ctrl+k followed by a two-character sequence. For en-dash, the sequence is -N. As Quincy pointed out, U+2014 is em-dash. If you want to enter that using digraphs, the sequence is -M.


Preface: This has nothing to do with Vim as such, but I will show you what I consider to be the "best" way to insert these characters by far; Vim's digraph system is more or less the same, but it only works with Vim. This will work in all applications. This will only work for X11 systems (Linux, BSD, etc.). For Windows, there's AllChars. It hasn't been ...


To insert Unicode characters such as the euro or copyright symbols, or diacritical marks such as the German umlaut or accent grave, digraphs can be used. For example, in insert mode press Ctrl+k and type the following: Spanish: a' for á, E' for É, n? for ñ, German: a: for ä, ss for ß, other accented letters: a! for à, a> for â for ê, a? for ã, Greek: a* ...


If there isn't a predefined digraph or you want a more memorable key sequence, then you can define digraphs in your vimrc. For example, the below will define two digraphs for en dash (8211) and em dash (8212) which mirror their XCompose sequences. digraph -. 8211 -- 8212 The :digraph command expects the value to be specified in decimal rather than hex, ...


The standard way of inserting an en dash in Vim is to use a digraph, as tommcdo explained. However, I find digraphs in general, and particularly this one (Ctrl+k, -, Shift+N) pretty awkward to type. For faster input of dashes, you could add the following pair of insert-mode mappings to a filetype file, such as .vim/after/ftplugin/markdown.vim. For en/em ...


My unicode plugin allows for easy input of unicode characters. Specifically it allows :Digraph <name> - Search digraphs for character :UnicodeTable - Displays a characterset table :UnicodeName - Identify character under cursor Completing of characters using their names or values from the unicode table (:h i_CTRL-X_CTRL-Z) or the digarphs (:h i_CTRL-...


Not really a job for Vim. Use make or a plain bash script to run your tests. You can use Vim's :make integration to run the whole battery from the editor. :help makeprg if you are not writing a Makefile. Example Makefile: test: *.in %.in: FORCE java MyProgram $@ FORCE: Then a simple :make (or :make test, if you defined other rules) will suffice. If ...


For commonly used characters, :digraph or external means such as the mentioned Compose key are great. For rarely used ones, I define abbreviations, like this: norea <unique> unicode_smiley 😃 norea <unique> unicode_skull ☠ And then use my SnippetComplete plugin to get a popup menu that list all such abbreviations, e.g. : unicode_<C-x>]


In adition to using the predefined digraphs (Run :dig to get a list), you can also define your own digraphs in vim: :digr e: 235 a: 228 See also: http://vimdoc.sourceforge.net/htmldoc/digraph.html


Install my unicode plugin, enter Vim and type DASH followed by CtrlXCtrlZ to activate unicode completion. (Note the -N in the description which shows the digraph to enter that character)


On my French AZERTY Mac keyboard, I can insert an en dash with Alt+-. Your mileage may obviously vary.


In the :terminal, you can put any register using (<c-w> = ctrl w): <c-w>"{register} In particular, to insert the contents of a variable you can use the expression register: <c-w>"= g:variable <cr> If you are writing a script, in vim's terminal you may use the function term_sendkeys to send the contents of a variable to the ...


Here's a hacky solution. You can write a script to change your input mode using AppleScript. Create a file ~/.vim/switch_im.applescript with the following contents: tell application "System Events" key code 49 using command down end tell This changes input method by emulating a Command+Space key press. (N.B. I'm using Command because that's the ...


I believe it is fine to use either :put or setline(). But as you are reading the contents from an external program, you could consider :read !: :[range]r[ead] [++opt] !{cmd} Execute {cmd} and insert its standard output below the cursor or the specified line. A temporary file is used to store the output of the command ...

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