You are not logged in.

#1 2017-06-02 01:03:52

maxemillian
Member
Registered: 2017-06-02
Posts: 7

When opening a file in vim, the file's contents is not displayed.

Hi all,

I am trying to enable terminal vim as my default text editor, and have arch associate text files with vim, and open them in a terminal window (I'm using Termite) when the files are opened.

I have succeeded in having arch launch vim after opening a text file.

I did this by creating a vim.desktop file in ~/.local/share/applications and then setting: export EDITOR=vim export VISUAL=vim. And finally I associated vim.desktop with plain text using xdg-mime default vim.desktop text/plain.

But the problem is that now, when I double click on a plain text file, vim opens, but at its initial screen; the contents of the file are no-where to be seen.

Is there something I'm missing here?

Here's the contents of my vim.desktop file.

[Desktop Entry]
Name=Vim Text Editor
Comment=Edit text files
Exec=vim
Terminal=true
Type=Application
Icon=terminal
Categories=Utility;TextEditor;
StartupNotify=true
MimeType=text/plain;

Thanks!

Last edited by maxemillian (2017-06-02 01:05:36)

Offline

#2 2017-06-02 01:10:27

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: When opening a file in vim, the file's contents is not displayed.

Your desktop file tells vim to open, but doesn't tell it what file to open.

Try

Exec=vim %f

or

Exec=vim %u

Last edited by 2ManyDogs (2017-06-02 01:15:15)

Offline

#3 2017-06-02 01:40:32

maxemillian
Member
Registered: 2017-06-02
Posts: 7

Re: When opening a file in vim, the file's contents is not displayed.

Neither of those have had any effect after editing the file then rebooting.

Is there another command I need to enter to commit have those edits into the system?

Or perhaps something else I can do?

Here's my vim.desktop file as it now stands:

[Desktop Entry]
Name=Vim Text Editor
Comment=Edit text files
Exec=vim %f
Terminal=true
Type=Application
Icon=terminal
Categories=Utility;TextEditor;
StartupNotify=true
MimeType=text/plain;

Thanks again

Offline

#4 2017-06-02 01:46:59

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: When opening a file in vim, the file's contents is not displayed.

Does the one that ships with Vim not work? https://github.com/vim/vim/blob/master/ … im.desktop


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2017-06-02 02:05:17

maxemillian
Member
Registered: 2017-06-02
Posts: 7

Re: When opening a file in vim, the file's contents is not displayed.

No that didn't work either.

I feel like there's something I've done wrong that's probably a very simple fix, but I have no idea what it is.

Anything else I should look into?

thanks a lot

Offline

#6 2017-06-02 02:08:04

maxemillian
Member
Registered: 2017-06-02
Posts: 7

Re: When opening a file in vim, the file's contents is not displayed.

Do I need to be re-entering any commands after editing the vim.desktop file? Or is a logout/reboot sufficient for the system to pick up on the changes?

Thanks,

Offline

#7 2017-06-02 02:25:34

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: When opening a file in vim, the file's contents is not displayed.

Have you change vim colorscheme or your terminal theme recently??

Offline

#8 2017-06-02 02:32:10

maxemillian
Member
Registered: 2017-06-02
Posts: 7

Re: When opening a file in vim, the file's contents is not displayed.

I have installed some vim colorschemes. I don't have any termite themes.

here is a paste of my .vimrc, is there anything which stands out to you?

set nocompatible              " be iMproved, required
filetype off                  " required
filetype plugin indent on
syntax on

"BASIC SETTINGS
set encoding=utf-8
set nu
"set spell spelllang=en_gb
set nocompatible              " be iMproved, required
filetype off                  " required
set tabstop=4


" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required

"MY PLUGINS
Plugin 'VundleVim/Vundle.vim'
Plugin 'junegunn/goyo.vim'
Plugin 'jakykong/vim-zim'
Plugin 'reedes/vim-pencil'
"Plugin 'joanrivera/vim-zimwiki-syntax'
"COLORSCHEMES
Plugin 'robertmeta/nofrils'


" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
"Plugin 'tpope/vim-fugitive'
" plugin from [url]http://vim-scripts.org/vim/scripts.html[/url]
" Plugin 'L9'
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

Last edited by maxemillian (2017-06-02 02:36:49)

Offline

#9 2017-06-02 02:34:51

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: When opening a file in vim, the file's contents is not displayed.

Please use code tags when pasting to the boards: https://wiki.archlinux.org/index.php/Co … s_and_code


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#10 2017-06-02 02:35:49

maxemillian
Member
Registered: 2017-06-02
Posts: 7

Re: When opening a file in vim, the file's contents is not displayed.

Oops, sorry!

Offline

#11 2017-06-02 02:52:14

maxemillian
Member
Registered: 2017-06-02
Posts: 7

Re: When opening a file in vim, the file's contents is not displayed.

Does the

TryExec=vim

command need to be there?

Offline

#12 2017-06-02 03:13:37

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: When opening a file in vim, the file's contents is not displayed.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#13 2017-06-02 06:28:23

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: When opening a file in vim, the file's contents is not displayed.

You may try starting vim without reading .vimrc with

vim -u NONE

, if this works it will confirm that problem is with .vimrc.

I don't use vundle or those plugins, so I am not sure what may be wrong there.

Offline

#14 2017-06-02 06:47:28

seth
Member
Registered: 2012-09-03
Posts: 59,012

Re: When opening a file in vim, the file's contents is not displayed.

Open a file and run

ps -Ao comm,args | grep vim

What's the output?

"vim %u" will btw. likely not work.

Offline

#15 2024-10-26 19:02:30

hejas
Member
Registered: 2024-09-03
Posts: 7

Re: When opening a file in vim, the file's contents is not displayed.

I had the same issue and in my case the problem was that my terminal wasn't supported by gtk-launch (i.e. not in the hard-coded list of terminals), prompting me to implement solution 2 from here to fix this. After that I was in the same state as OP.

The problem: That solution doesn't pass any additional arguments given to gtk-launch (such as the filename) onto vim, explaining everything that was happening. In my case I fixed it by changing $1 in the script from the above link to "$@", to pass all arguments.

Last edited by hejas (2024-10-26 19:04:14)

Offline

Board footer

Powered by FluxBB