Hot answers tagged

6

In the replacement side of vim substitution, a newline is represented by \r. Thus, try: %s/\n\n/#\r\r/g The resulting file will look like: elephant# rhino# giraffe# /* animals who live in Africa */ In the first half of a substitute command, \n is a newline and \r is a carriage return. By contrast, in the replacement side of the command, \n is a ...


2

I'm not much of a vim coder, though the following .vimrc foo appears to abort vim should a directory be present in the arguments: autocmd VimEnter * call QuitIfDirectory() function QuitIfDirectory() for f in argv() if isdirectory(f) " avoid "whoops, more things to edit" case if(argc()>1) last endif echomsg "cowardly ...



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