reddit / emacs

Please help me in translating my vimrc to emacs equivalents.

LowCom · 2022-04-27 13:38
For those who came from vim, can you tell me the equivalent settings and plugins for emacs? "basic visual settings set number set linebreak "text type settings set encoding=utf-8 "Remapping keys inoremap jk <Esc> nnoremap j gj nnoremap k gk "to quickly open NERDTree filebrowser. nnoremap <F5> :NERDTree<CR> "to open files with external programs from paths written in vim. nnoremap gF :!xdg-open <cfile><CR> "to make Y behave similar to D and C nnoremap Y y$ "to make a new line after the word without entering insert mode nnoremap <leader>e a<CR><Esc> "insert a new line without entering insert mode nnoremap <leader>o o<Esc>k nnoremap <leader>O O<Esc>j "search settings set hlsearch set incsearch "clipboard settings set clipboard=unnamedplus "for use of Vim plug plugin manager. call plug#begin() " To change the surroundings a text. Plug 'https://github.com/tpope/vim-surround' " A Vim Plugin for Lively Previewing LaTeX PDF Output " Use this command to start the previewer :LLPStartPreview Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } Plug 'https://github.com/vimwiki/vimwiki' "It is a file browser and does basic file ops. Plug 'preservim/nerdtree' "It highlights most movement commands like w,j,f,t,/ etc.Triggered by "leader twice plus the movement key. Plug 'https://github.com/easymotion/vim-easymotion.git' "enables completion with tab instead of control p. Plug 'https://github.com/ervandew/supertab' "To edit csv files in vim and display them nicely. Plug 'chrisbra/csv.vim' "To make org mode like tables in vim with spreadsheet capabilities. Plug 'https://github.com/dhruvasagar/vim-table-mode' "To use org mode of emacs in vim, but tables not supported and not maintained. Plug 'jceb/vim-orgmode' "It opens a calendar in vim which is read only, like in emacs. Plug 'https://github.com/mattn/calendar-vim' call plug#end() "settings required by plugins. "to use markdown in vimwiki instead of learning vimwiki syntax let g:vimwiki_list = [{'path': '~/vimwiki/', \ 'syntax': 'markdown', 'ext': '.md'}] "to make markdown compatible tables in vim-table-mode plugin. let g:table_mode_corner='|' "Self defined commands which can be executed on vim command line.(must start "with caps) "This is shortcut for quickly sourcing vimrc. command Src source ~/.vimrc "shortcut to delete entire file. command Dal norm ggdG "shortcut to copy entire file. command Yal norm ggyG command Erc vsplit ~/.vimrc "to make presentations with pandoc using source markdown and then opening the pdf through external viewer. command Mkppt :!pandoc % -t beamer -o output.pdf ; xdg-open output.pdf "changing the default leader key which is "\" let mapleader = "\<Space>" "auto commands to do stuff based on certain events "This inserts # when leader + c key is pressed in a python file. autocmd filetype python nnoremap <leader>c I#<Esc> autocmd filetype python nnoremap <leader>C ^x<Esc> "saving macros or registers. "macro for anki cloze deletion let @b="f:a{{c1::jkA}}jkj0"
ntwmbc · 2022-04-27 13:50
Some of these I know. For example, nerdtree in vim is similar to neotree or treemacs in emacs. However, some I don't know what they do. It would be easier if you added a comment to each, saying what it does. Even better would be if you said what it did, googled a bit, and evaluated some alternatives for yourself. Doom emacs was made by a vim refugee and might be a good starting point if you want a vim-like workflow. It includes packages like treemacs. My hunch is that once you have doom emacs, porting your .vimrc will be much easier than if you just start from scratch.
LowCom · 2022-04-27 14:09
> It would be easier if you added a comment to each, saying what it does I did add a comment before every line, stating what the setting or plugin is for. Thanks for the doom emacs recommendation. I had trouble installing it on my manjaro linux for some reason.
ntwmbc · 2022-04-27 14:30
Well, yes, but this doesn't mean anything to me: "basic visual settings set number set linebreak I know what numbers and linebreaks are, but it's not clear why you need to set them, or what it has to do with visual settings. What issues did you have installing on manjaro? Again, I think that's the starting point you want.
LowCom · 2022-04-27 15:07
Oh sorry, I didn't comment on those two lines as I thought they would be self explanatory. " To display line numbers in vim like in an IDE. set number "When making new line, don't create a new line in the middle of a word i.e don't split words to make a new line. set linebreak Rest of them all are commented. I don't remember what the error was then with doom emacs. But I will try to run it again. I should remove "evil mode" right, for doom emacs to work? So it won't conflict with that?
DefiantAverage1 · 2022-04-27 15:08
I don't have time now but I can help you out tomorrow
oantolin · 2022-04-27 20:50
`set number` corresponds to `(global-display-line-numbers-mode)`, and `set linebreak` to `(visual-line-mode)`.
oantolin · 2022-04-27 20:58
Your `command Src source ~/.vimrc` corresponds to defining a command: (defun reload-init-file () "Reload the `user-init-file'." (interactive) (load user-init-file)) You can then bind that to a key or invoke by name it via `M-x`.
DefiantAverage1 · 2022-04-28 10:33
I got through a bit of the translation: [https://gist.github.com/anonimitoraf/9b58286dfc92965cba8e03c7d46e8971](https://gist.github.com/anonimitoraf/9b58286dfc92965cba8e03c7d46e8971) but I just realized, you're probably better off using [doom emacs](https://github.com/hlissner/doom-emacs). The defaults are sane, customizations are almost always optional and the [community](https://github.com/hlissner/doom-emacs)'s really active/helpful. (Disclaimer: I'm a doom emacs user with \~2k lines of [config](https://github.com/anonimitoraf/doom.d/blob/master/config-sections/packages.org))