2

I need to setup Emacs editor by preparing the ~/.emacs configuration file. I have been using Vim for years and now I want to switch to Emacs for various reasons that are out of scope of this post. To do so, I need to reproduce in Emacs all the functionality of Vim that I worked out over years of using it. In other words: I want to transform my ~/.vimrc configuration file into the equivalent ~/.emacs configuration file. I include my ~/.vimrc with all settings commented in this post.

I know that my ~/.vimrc contains quite a lot of settings, but I have already figured out how transform some of them, and I am also aware that some of the settings don't really need to be transformed. Unfortunately, most of them are still beyond my current knowledge of Emacs configuration.

Here is my ~/.vimrc:

" Configuration file for Vi Improved, save as ~/.vimrc to use.
set nocompatible " Vim mode instead of pure Vi
set encoding=utf-8 " encoding used for displaying file
set fileencoding=utf-8 " encoding used when saving file
set nobackup " do not keep the backup~ file
set confirm " confirm :q in case of unsaved changes
set ruler " show the cursor position all the time
set textwidth=80 " wrap lines automatically at 80th column
set tabstop=8 " set tabulator length to 8 columns
set expandtab " fill tabs with spaces
set softtabstop=8 " backspacing over 8 spaces like over tabs
set shiftwidth=8 " set indentation depth to 8 columns
set backspace=indent,eol,start " backspacing over everything in insert mode
set nojoinspaces " no extra space after '.' when joining lines
set incsearch " do incremental search
set ignorecase " do case insensitive search...
set smartcase " ...unless capital letters are used
set hlsearch " highlight search results
set showmatch " highlight matching braces

filetype on " enable file type detection
filetype plugin on " load the plugins for specific file types
filetype indent on " automatically indent code...
set cinoptions=:0g0 " ...but don't indent case labels and access modifiers

syntax enable " syntax highlighting
set background=dark " dark background for console
colorscheme solarized " set color scheme, must be installed before use

" characters for displaying non-printable characters
set listchars=eol:$,tab:>-,trail:.,nbsp:_,extends:+,precedes:+

" tuning for gVim only
if has('gui_running')
    set number " show line numbers
    set columns=84 lines=48 " GUI window geometry
    set guifont=Monospace\ 12 " font for GUI window
    set background=light " light background for GUI
endif

" automatic commands
if has('autocmd')
    " file type specific automatic commands

    " don't replace Tabs with spaces when editing makefiles
    autocmd Filetype makefile setlocal noexpandtab

    " press F5 to call `indent` for C and C++ source code files
    autocmd FileType c,cpp noremap <F5> :%!indent -kr -brf -nut<cr>
    autocmd FileType c,cpp inoremap <F5> <Esc>:%!indent -kr -brf -nut<cr>

    " tuning textwidth for Java code
    autocmd FileType java setlocal textwidth=132
    if has('gui_running')
        autocmd FileType java setlocal columns=136
    endif

    " disable automatic code indentation when editing TeX and XML files
    autocmd FileType tex,xml setlocal indentexpr=

    " clean-up commands that run automatically on write; use with caution

    " delete empty or whitespaces-only lines at the end of file
    autocmd BufWritePre * :%s/\(\s*\n\)\+\%$//ge

    " replace groups of empty or whitespaces-only lines with one empty line
    autocmd BufWritePre * :%s/\(\s*\n\)\{3,}/\r\r/ge

    " delete any trailing whitespaces
    autocmd BufWritePre * :%s/\s\+$//ge
endif

" general key mappings

" center view on the search result
noremap n nzz
noremap N Nzz

" press F4 to fix indentation in whole file; overwrites marker 'q' position
noremap <F4> mqggVG=`qzz
inoremap <F4> <Esc>mqggVG=`qzza

" press F8 to turn the search results highlight off
noremap <F8> :nohl<cr>
inoremap <F8> <Esc>:nohl<cr>a 

" press F12 to toggle showing the non-printable charactes
noremap <F12> :set list!<cr>
inoremap <F12> <Esc>:set list!<cr>a

closed as too broad by muru, Ravexina, Sumeet Deshmukh, Eric Carvalho, Wild Man Jun 1 '17 at 4:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

0

Unfortunately there's no automated way to do this. Have you have probably made progress and/or no longer need this answer?

Your question isn't very specific. You mention you have already figured out a lot of your conversion, and some don't need to be transformed. Which still do?

There is a vim mode for emacs called evil that might be interesting. They have a youtube video too.